Search in sources :

Example 1 with Location

use of de.pdark.decentxml.Location in project sling by apache.

the class TolerantXMLTokenizer method parseAttribute.

@Override
protected void parseAttribute(Token token) {
    token.setType(Type.ATTRIBUTE);
    parseName("attribute");
    if (pos == token.getStartOffset())
        throw new XMLParseException("Expected attribute name", source, pos);
    skipWhiteSpace();
    expect('=');
    skipWhiteSpace();
    char c = 0;
    if (pos < source.length())
        c = source.charAt(pos);
    if (c != '\'' && c != '"')
        throw new XMLParseException("Expected single or double quotes", source, pos);
    char endChar = c;
    while (true) {
        pos++;
        if (pos >= source.length()) {
            int i = Math.min(20, source.length() - token.getStartOffset());
            throw new XMLParseException("Missing end quote (" + endChar + ") of attribute: " + lookAheadForErrorMessage(null, token.getStartOffset(), i), token);
        }
        c = source.charAt(pos);
        if (c == endChar)
            break;
        if (c == '<') {
            Location l = new Location(source, pos);
            System.err.println("Illegal character in attribute value: '" + c + "' in " + originDetails + " at " + l);
        }
    }
    // Skip end-char
    pos++;
}
Also used : XMLParseException(de.pdark.decentxml.XMLParseException) Location(de.pdark.decentxml.Location)

Aggregations

Location (de.pdark.decentxml.Location)1 XMLParseException (de.pdark.decentxml.XMLParseException)1