Java Code Examples for com.sun.org.apache.xerces.internal.util.SymbolTable#addSymbol()

The following examples show how to use com.sun.org.apache.xerces.internal.util.SymbolTable#addSymbol() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XSDocumentInfo.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
XSDocumentInfo (Element schemaRoot, XSAttributeChecker attrChecker, SymbolTable symbolTable)
                throws XMLSchemaException {
    fSchemaElement = schemaRoot;
    initNamespaceSupport(schemaRoot);
    fIsChameleonSchema = false;

    fSymbolTable = symbolTable;
    fAttrChecker = attrChecker;

    if (schemaRoot != null) {
        Element root = schemaRoot;
        fSchemaAttrs = attrChecker.checkAttributes(root, true, this);
        // schemaAttrs == null means it's not an <xsd:schema> element
        // throw an exception, but we don't know the document systemId,
        // so we leave that to the caller.
        if (fSchemaAttrs == null) {
            throw new XMLSchemaException(null, null);
        }
        fAreLocalAttributesQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_AFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fAreLocalElementsQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_EFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fBlockDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_BLOCKDEFAULT]).shortValue();
        fFinalDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_FINALDEFAULT]).shortValue();
        fTargetNamespace =
            (String)fSchemaAttrs[XSAttributeChecker.ATTIDX_TARGETNAMESPACE];
        if (fTargetNamespace != null)
            fTargetNamespace = symbolTable.addSymbol(fTargetNamespace);

        fNamespaceSupportRoot = new SchemaNamespaceSupport(fNamespaceSupport);

        //set namespace support
        fValidationContext.setNamespaceSupport(fNamespaceSupport);
        fValidationContext.setSymbolTable(symbolTable);
        // pass null as the schema document, so that the namespace
        // context is not popped.

        // don't return the attribute array yet!
        //attrChecker.returnAttrArray(schemaAttrs, null);
    }
}
 
Example 2
Source File: ElementSchemePointer.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Scans the XPointer Expression
 *
 */
private boolean scanExpr(SymbolTable symbolTable, Tokens tokens,
        String data, int currentOffset, int endOffset)
        throws XNIException {

    int ch;
    int nameOffset;
    String nameHandle = null;

    while (true) {
        if (currentOffset == endOffset) {
            break;
        }

        ch = data.charAt(currentOffset);
        byte chartype = (ch >= 0x80) ? CHARTYPE_NONASCII
                : fASCIICharMap[ch];

        //
        // [1]    ElementSchemeData    ::=    (NCName ChildSequence?) | ChildSequence
        // [2]    ChildSequence    ::=    ('/' [1-9] [0-9]*)+
        //

        switch (chartype) {

        case CHARTYPE_SLASH:
            // if last character is '/', break and report an error
            if (++currentOffset == endOffset) {
                return false;
            }

            addToken(tokens, Tokens.XPTRTOKEN_ELEM_CHILD);
            ch = data.charAt(currentOffset);

            // ChildSequence    ::=    ('/' [1-9] [0-9]*)+
            int child = 0;
            while (ch >= '0' && ch <= '9') {
                child = (child * 10) + (ch - '0');
                if (++currentOffset == endOffset) {
                    break;
                }
                ch = data.charAt(currentOffset);
            }

            // An invalid child sequence character
            if (child == 0) {
                reportError("InvalidChildSequenceCharacter",
                        new Object[] { new Character((char) ch) });
                return false;
            }

            tokens.addToken(child);

            break;

        case CHARTYPE_DIGIT:
        case CHARTYPE_LETTER:
        case CHARTYPE_MINUS:
        case CHARTYPE_NONASCII:
        case CHARTYPE_OTHER:
        case CHARTYPE_PERIOD:
        case CHARTYPE_UNDERSCORE:
            // Scan the ShortHand Pointer NCName
            nameOffset = currentOffset;
            currentOffset = scanNCName(data, endOffset, currentOffset);

            if (currentOffset == nameOffset) {
                //return false;
                reportError("InvalidNCNameInElementSchemeData",
                        new Object[] { data });
                return false;
            }

            if (currentOffset < endOffset) {
                ch = data.charAt(currentOffset);
            } else {
                ch = -1;
            }

            nameHandle = symbolTable.addSymbol(data.substring(
                    nameOffset, currentOffset));
            addToken(tokens, Tokens.XPTRTOKEN_ELEM_NCNAME);
            tokens.addToken(nameHandle);

            break;
        }
    }
    return true;
}
 
Example 3
Source File: XSDocumentInfo.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
XSDocumentInfo (Element schemaRoot, XSAttributeChecker attrChecker, SymbolTable symbolTable)
                throws XMLSchemaException {
    fSchemaElement = schemaRoot;
    initNamespaceSupport(schemaRoot);
    fIsChameleonSchema = false;

    fSymbolTable = symbolTable;
    fAttrChecker = attrChecker;

    if (schemaRoot != null) {
        Element root = schemaRoot;
        fSchemaAttrs = attrChecker.checkAttributes(root, true, this);
        // schemaAttrs == null means it's not an <xsd:schema> element
        // throw an exception, but we don't know the document systemId,
        // so we leave that to the caller.
        if (fSchemaAttrs == null) {
            throw new XMLSchemaException(null, null);
        }
        fAreLocalAttributesQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_AFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fAreLocalElementsQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_EFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fBlockDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_BLOCKDEFAULT]).shortValue();
        fFinalDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_FINALDEFAULT]).shortValue();
        fTargetNamespace =
            (String)fSchemaAttrs[XSAttributeChecker.ATTIDX_TARGETNAMESPACE];
        if (fTargetNamespace != null)
            fTargetNamespace = symbolTable.addSymbol(fTargetNamespace);

        fNamespaceSupportRoot = new SchemaNamespaceSupport(fNamespaceSupport);

        //set namespace support
        fValidationContext.setNamespaceSupport(fNamespaceSupport);
        fValidationContext.setSymbolTable(symbolTable);
        // pass null as the schema document, so that the namespace
        // context is not popped.

        // don't return the attribute array yet!
        //attrChecker.returnAttrArray(schemaAttrs, null);
    }
}
 
Example 4
Source File: ElementSchemePointer.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Scans the XPointer Expression
 *
 */
private boolean scanExpr(SymbolTable symbolTable, Tokens tokens,
        String data, int currentOffset, int endOffset)
        throws XNIException {

    int ch;
    int nameOffset;
    String nameHandle = null;

    while (true) {
        if (currentOffset == endOffset) {
            break;
        }

        ch = data.charAt(currentOffset);
        byte chartype = (ch >= 0x80) ? CHARTYPE_NONASCII
                : fASCIICharMap[ch];

        //
        // [1]    ElementSchemeData    ::=    (NCName ChildSequence?) | ChildSequence
        // [2]    ChildSequence    ::=    ('/' [1-9] [0-9]*)+
        //

        switch (chartype) {

        case CHARTYPE_SLASH:
            // if last character is '/', break and report an error
            if (++currentOffset == endOffset) {
                return false;
            }

            addToken(tokens, Tokens.XPTRTOKEN_ELEM_CHILD);
            ch = data.charAt(currentOffset);

            // ChildSequence    ::=    ('/' [1-9] [0-9]*)+
            int child = 0;
            while (ch >= '0' && ch <= '9') {
                child = (child * 10) + (ch - '0');
                if (++currentOffset == endOffset) {
                    break;
                }
                ch = data.charAt(currentOffset);
            }

            // An invalid child sequence character
            if (child == 0) {
                reportError("InvalidChildSequenceCharacter",
                        new Object[] { new Character((char) ch) });
                return false;
            }

            tokens.addToken(child);

            break;

        case CHARTYPE_DIGIT:
        case CHARTYPE_LETTER:
        case CHARTYPE_MINUS:
        case CHARTYPE_NONASCII:
        case CHARTYPE_OTHER:
        case CHARTYPE_PERIOD:
        case CHARTYPE_UNDERSCORE:
            // Scan the ShortHand Pointer NCName
            nameOffset = currentOffset;
            currentOffset = scanNCName(data, endOffset, currentOffset);

            if (currentOffset == nameOffset) {
                //return false;
                reportError("InvalidNCNameInElementSchemeData",
                        new Object[] { data });
                return false;
            }

            if (currentOffset < endOffset) {
                ch = data.charAt(currentOffset);
            } else {
                ch = -1;
            }

            nameHandle = symbolTable.addSymbol(data.substring(
                    nameOffset, currentOffset));
            addToken(tokens, Tokens.XPTRTOKEN_ELEM_NCNAME);
            tokens.addToken(nameHandle);

            break;
        }
    }
    return true;
}
 
Example 5
Source File: XSDocumentInfo.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
XSDocumentInfo (Element schemaRoot, XSAttributeChecker attrChecker, SymbolTable symbolTable)
                throws XMLSchemaException {
    fSchemaElement = schemaRoot;
    initNamespaceSupport(schemaRoot);
    fIsChameleonSchema = false;

    fSymbolTable = symbolTable;
    fAttrChecker = attrChecker;

    if (schemaRoot != null) {
        Element root = schemaRoot;
        fSchemaAttrs = attrChecker.checkAttributes(root, true, this);
        // schemaAttrs == null means it's not an <xsd:schema> element
        // throw an exception, but we don't know the document systemId,
        // so we leave that to the caller.
        if (fSchemaAttrs == null) {
            throw new XMLSchemaException(null, null);
        }
        fAreLocalAttributesQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_AFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fAreLocalElementsQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_EFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fBlockDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_BLOCKDEFAULT]).shortValue();
        fFinalDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_FINALDEFAULT]).shortValue();
        fTargetNamespace =
            (String)fSchemaAttrs[XSAttributeChecker.ATTIDX_TARGETNAMESPACE];
        if (fTargetNamespace != null)
            fTargetNamespace = symbolTable.addSymbol(fTargetNamespace);

        fNamespaceSupportRoot = new SchemaNamespaceSupport(fNamespaceSupport);

        //set namespace support
        fValidationContext.setNamespaceSupport(fNamespaceSupport);
        fValidationContext.setSymbolTable(symbolTable);
        // pass null as the schema document, so that the namespace
        // context is not popped.

        // don't return the attribute array yet!
        //attrChecker.returnAttrArray(schemaAttrs, null);
    }
}
 
Example 6
Source File: ElementSchemePointer.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Scans the XPointer Expression
 *
 */
private boolean scanExpr(SymbolTable symbolTable, Tokens tokens,
        String data, int currentOffset, int endOffset)
        throws XNIException {

    int ch;
    int nameOffset;
    String nameHandle = null;

    while (true) {
        if (currentOffset == endOffset) {
            break;
        }

        ch = data.charAt(currentOffset);
        byte chartype = (ch >= 0x80) ? CHARTYPE_NONASCII
                : fASCIICharMap[ch];

        //
        // [1]    ElementSchemeData    ::=    (NCName ChildSequence?) | ChildSequence
        // [2]    ChildSequence    ::=    ('/' [1-9] [0-9]*)+
        //

        switch (chartype) {

        case CHARTYPE_SLASH:
            // if last character is '/', break and report an error
            if (++currentOffset == endOffset) {
                return false;
            }

            addToken(tokens, Tokens.XPTRTOKEN_ELEM_CHILD);
            ch = data.charAt(currentOffset);

            // ChildSequence    ::=    ('/' [1-9] [0-9]*)+
            int child = 0;
            while (ch >= '0' && ch <= '9') {
                child = (child * 10) + (ch - '0');
                if (++currentOffset == endOffset) {
                    break;
                }
                ch = data.charAt(currentOffset);
            }

            // An invalid child sequence character
            if (child == 0) {
                reportError("InvalidChildSequenceCharacter",
                        new Object[] { new Character((char) ch) });
                return false;
            }

            tokens.addToken(child);

            break;

        case CHARTYPE_DIGIT:
        case CHARTYPE_LETTER:
        case CHARTYPE_MINUS:
        case CHARTYPE_NONASCII:
        case CHARTYPE_OTHER:
        case CHARTYPE_PERIOD:
        case CHARTYPE_UNDERSCORE:
            // Scan the ShortHand Pointer NCName
            nameOffset = currentOffset;
            currentOffset = scanNCName(data, endOffset, currentOffset);

            if (currentOffset == nameOffset) {
                //return false;
                reportError("InvalidNCNameInElementSchemeData",
                        new Object[] { data });
                return false;
            }

            if (currentOffset < endOffset) {
                ch = data.charAt(currentOffset);
            } else {
                ch = -1;
            }

            nameHandle = symbolTable.addSymbol(data.substring(
                    nameOffset, currentOffset));
            addToken(tokens, Tokens.XPTRTOKEN_ELEM_NCNAME);
            tokens.addToken(nameHandle);

            break;
        }
    }
    return true;
}
 
Example 7
Source File: ElementSchemePointer.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Scans the XPointer Expression
 *
 */
private boolean scanExpr(SymbolTable symbolTable, Tokens tokens,
        String data, int currentOffset, int endOffset)
        throws XNIException {

    int ch;
    int nameOffset;
    String nameHandle = null;

    while (true) {
        if (currentOffset == endOffset) {
            break;
        }

        ch = data.charAt(currentOffset);
        byte chartype = (ch >= 0x80) ? CHARTYPE_NONASCII
                : fASCIICharMap[ch];

        //
        // [1]    ElementSchemeData    ::=    (NCName ChildSequence?) | ChildSequence
        // [2]    ChildSequence    ::=    ('/' [1-9] [0-9]*)+
        //

        switch (chartype) {

        case CHARTYPE_SLASH:
            // if last character is '/', break and report an error
            if (++currentOffset == endOffset) {
                return false;
            }

            addToken(tokens, Tokens.XPTRTOKEN_ELEM_CHILD);
            ch = data.charAt(currentOffset);

            // ChildSequence    ::=    ('/' [1-9] [0-9]*)+
            int child = 0;
            while (ch >= '0' && ch <= '9') {
                child = (child * 10) + (ch - '0');
                if (++currentOffset == endOffset) {
                    break;
                }
                ch = data.charAt(currentOffset);
            }

            // An invalid child sequence character
            if (child == 0) {
                reportError("InvalidChildSequenceCharacter",
                        new Object[] { new Character((char) ch) });
                return false;
            }

            tokens.addToken(child);

            break;

        case CHARTYPE_DIGIT:
        case CHARTYPE_LETTER:
        case CHARTYPE_MINUS:
        case CHARTYPE_NONASCII:
        case CHARTYPE_OTHER:
        case CHARTYPE_PERIOD:
        case CHARTYPE_UNDERSCORE:
            // Scan the ShortHand Pointer NCName
            nameOffset = currentOffset;
            currentOffset = scanNCName(data, endOffset, currentOffset);

            if (currentOffset == nameOffset) {
                //return false;
                reportError("InvalidNCNameInElementSchemeData",
                        new Object[] { data });
                return false;
            }

            if (currentOffset < endOffset) {
                ch = data.charAt(currentOffset);
            } else {
                ch = -1;
            }

            nameHandle = symbolTable.addSymbol(data.substring(
                    nameOffset, currentOffset));
            addToken(tokens, Tokens.XPTRTOKEN_ELEM_NCNAME);
            tokens.addToken(nameHandle);

            break;
        }
    }
    return true;
}
 
Example 8
Source File: ElementSchemePointer.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * Scans the XPointer Expression
 *
 */
private boolean scanExpr(SymbolTable symbolTable, Tokens tokens,
        String data, int currentOffset, int endOffset)
        throws XNIException {

    int ch;
    int nameOffset;
    String nameHandle = null;

    while (true) {
        if (currentOffset == endOffset) {
            break;
        }

        ch = data.charAt(currentOffset);
        byte chartype = (ch >= 0x80) ? CHARTYPE_NONASCII
                : fASCIICharMap[ch];

        //
        // [1]    ElementSchemeData    ::=    (NCName ChildSequence?) | ChildSequence
        // [2]    ChildSequence    ::=    ('/' [1-9] [0-9]*)+
        //

        switch (chartype) {

        case CHARTYPE_SLASH:
            // if last character is '/', break and report an error
            if (++currentOffset == endOffset) {
                return false;
            }

            addToken(tokens, Tokens.XPTRTOKEN_ELEM_CHILD);
            ch = data.charAt(currentOffset);

            // ChildSequence    ::=    ('/' [1-9] [0-9]*)+
            int child = 0;
            while (ch >= '0' && ch <= '9') {
                child = (child * 10) + (ch - '0');
                if (++currentOffset == endOffset) {
                    break;
                }
                ch = data.charAt(currentOffset);
            }

            // An invalid child sequence character
            if (child == 0) {
                reportError("InvalidChildSequenceCharacter",
                        new Object[] { (char) ch });
                return false;
            }

            tokens.addToken(child);

            break;

        case CHARTYPE_DIGIT:
        case CHARTYPE_LETTER:
        case CHARTYPE_MINUS:
        case CHARTYPE_NONASCII:
        case CHARTYPE_OTHER:
        case CHARTYPE_PERIOD:
        case CHARTYPE_UNDERSCORE:
            // Scan the ShortHand Pointer NCName
            nameOffset = currentOffset;
            currentOffset = scanNCName(data, endOffset, currentOffset);

            if (currentOffset == nameOffset) {
                //return false;
                reportError("InvalidNCNameInElementSchemeData",
                        new Object[] { data });
                return false;
            }

            if (currentOffset < endOffset) {
                ch = data.charAt(currentOffset);
            } else {
                ch = -1;
            }

            nameHandle = symbolTable.addSymbol(data.substring(
                    nameOffset, currentOffset));
            addToken(tokens, Tokens.XPTRTOKEN_ELEM_NCNAME);
            tokens.addToken(nameHandle);

            break;
        }
    }
    return true;
}
 
Example 9
Source File: XSDocumentInfo.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
XSDocumentInfo (Element schemaRoot, XSAttributeChecker attrChecker, SymbolTable symbolTable)
                throws XMLSchemaException {
    fSchemaElement = schemaRoot;
    initNamespaceSupport(schemaRoot);
    fIsChameleonSchema = false;

    fSymbolTable = symbolTable;
    fAttrChecker = attrChecker;

    if (schemaRoot != null) {
        Element root = schemaRoot;
        fSchemaAttrs = attrChecker.checkAttributes(root, true, this);
        // schemaAttrs == null means it's not an <xsd:schema> element
        // throw an exception, but we don't know the document systemId,
        // so we leave that to the caller.
        if (fSchemaAttrs == null) {
            throw new XMLSchemaException(null, null);
        }
        fAreLocalAttributesQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_AFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fAreLocalElementsQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_EFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fBlockDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_BLOCKDEFAULT]).shortValue();
        fFinalDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_FINALDEFAULT]).shortValue();
        fTargetNamespace =
            (String)fSchemaAttrs[XSAttributeChecker.ATTIDX_TARGETNAMESPACE];
        if (fTargetNamespace != null)
            fTargetNamespace = symbolTable.addSymbol(fTargetNamespace);

        fNamespaceSupportRoot = new SchemaNamespaceSupport(fNamespaceSupport);

        //set namespace support
        fValidationContext.setNamespaceSupport(fNamespaceSupport);
        fValidationContext.setSymbolTable(symbolTable);
        // pass null as the schema document, so that the namespace
        // context is not popped.

        // don't return the attribute array yet!
        //attrChecker.returnAttrArray(schemaAttrs, null);
    }
}
 
Example 10
Source File: ElementSchemePointer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Scans the XPointer Expression
 *
 */
private boolean scanExpr(SymbolTable symbolTable, Tokens tokens,
        String data, int currentOffset, int endOffset)
        throws XNIException {

    int ch;
    int nameOffset;
    String nameHandle = null;

    while (true) {
        if (currentOffset == endOffset) {
            break;
        }

        ch = data.charAt(currentOffset);
        byte chartype = (ch >= 0x80) ? CHARTYPE_NONASCII
                : fASCIICharMap[ch];

        //
        // [1]    ElementSchemeData    ::=    (NCName ChildSequence?) | ChildSequence
        // [2]    ChildSequence    ::=    ('/' [1-9] [0-9]*)+
        //

        switch (chartype) {

        case CHARTYPE_SLASH:
            // if last character is '/', break and report an error
            if (++currentOffset == endOffset) {
                return false;
            }

            addToken(tokens, Tokens.XPTRTOKEN_ELEM_CHILD);
            ch = data.charAt(currentOffset);

            // ChildSequence    ::=    ('/' [1-9] [0-9]*)+
            int child = 0;
            while (ch >= '0' && ch <= '9') {
                child = (child * 10) + (ch - '0');
                if (++currentOffset == endOffset) {
                    break;
                }
                ch = data.charAt(currentOffset);
            }

            // An invalid child sequence character
            if (child == 0) {
                reportError("InvalidChildSequenceCharacter",
                        new Object[] { new Character((char) ch) });
                return false;
            }

            tokens.addToken(child);

            break;

        case CHARTYPE_DIGIT:
        case CHARTYPE_LETTER:
        case CHARTYPE_MINUS:
        case CHARTYPE_NONASCII:
        case CHARTYPE_OTHER:
        case CHARTYPE_PERIOD:
        case CHARTYPE_UNDERSCORE:
            // Scan the ShortHand Pointer NCName
            nameOffset = currentOffset;
            currentOffset = scanNCName(data, endOffset, currentOffset);

            if (currentOffset == nameOffset) {
                //return false;
                reportError("InvalidNCNameInElementSchemeData",
                        new Object[] { data });
                return false;
            }

            if (currentOffset < endOffset) {
                ch = data.charAt(currentOffset);
            } else {
                ch = -1;
            }

            nameHandle = symbolTable.addSymbol(data.substring(
                    nameOffset, currentOffset));
            addToken(tokens, Tokens.XPTRTOKEN_ELEM_NCNAME);
            tokens.addToken(nameHandle);

            break;
        }
    }
    return true;
}
 
Example 11
Source File: XSDocumentInfo.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
XSDocumentInfo (Element schemaRoot, XSAttributeChecker attrChecker, SymbolTable symbolTable)
                throws XMLSchemaException {
    fSchemaElement = schemaRoot;
    initNamespaceSupport(schemaRoot);
    fIsChameleonSchema = false;

    fSymbolTable = symbolTable;
    fAttrChecker = attrChecker;

    if (schemaRoot != null) {
        Element root = schemaRoot;
        fSchemaAttrs = attrChecker.checkAttributes(root, true, this);
        // schemaAttrs == null means it's not an <xsd:schema> element
        // throw an exception, but we don't know the document systemId,
        // so we leave that to the caller.
        if (fSchemaAttrs == null) {
            throw new XMLSchemaException(null, null);
        }
        fAreLocalAttributesQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_AFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fAreLocalElementsQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_EFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fBlockDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_BLOCKDEFAULT]).shortValue();
        fFinalDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_FINALDEFAULT]).shortValue();
        fTargetNamespace =
            (String)fSchemaAttrs[XSAttributeChecker.ATTIDX_TARGETNAMESPACE];
        if (fTargetNamespace != null)
            fTargetNamespace = symbolTable.addSymbol(fTargetNamespace);

        fNamespaceSupportRoot = new SchemaNamespaceSupport(fNamespaceSupport);

        //set namespace support
        fValidationContext.setNamespaceSupport(fNamespaceSupport);
        fValidationContext.setSymbolTable(symbolTable);
        // pass null as the schema document, so that the namespace
        // context is not popped.

        // don't return the attribute array yet!
        //attrChecker.returnAttrArray(schemaAttrs, null);
    }
}
 
Example 12
Source File: ElementSchemePointer.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Scans the XPointer Expression
 *
 */
private boolean scanExpr(SymbolTable symbolTable, Tokens tokens,
        String data, int currentOffset, int endOffset)
        throws XNIException {

    int ch;
    int nameOffset;
    String nameHandle = null;

    while (true) {
        if (currentOffset == endOffset) {
            break;
        }

        ch = data.charAt(currentOffset);
        byte chartype = (ch >= 0x80) ? CHARTYPE_NONASCII
                : fASCIICharMap[ch];

        //
        // [1]    ElementSchemeData    ::=    (NCName ChildSequence?) | ChildSequence
        // [2]    ChildSequence    ::=    ('/' [1-9] [0-9]*)+
        //

        switch (chartype) {

        case CHARTYPE_SLASH:
            // if last character is '/', break and report an error
            if (++currentOffset == endOffset) {
                return false;
            }

            addToken(tokens, Tokens.XPTRTOKEN_ELEM_CHILD);
            ch = data.charAt(currentOffset);

            // ChildSequence    ::=    ('/' [1-9] [0-9]*)+
            int child = 0;
            while (ch >= '0' && ch <= '9') {
                child = (child * 10) + (ch - '0');
                if (++currentOffset == endOffset) {
                    break;
                }
                ch = data.charAt(currentOffset);
            }

            // An invalid child sequence character
            if (child == 0) {
                reportError("InvalidChildSequenceCharacter",
                        new Object[] { new Character((char) ch) });
                return false;
            }

            tokens.addToken(child);

            break;

        case CHARTYPE_DIGIT:
        case CHARTYPE_LETTER:
        case CHARTYPE_MINUS:
        case CHARTYPE_NONASCII:
        case CHARTYPE_OTHER:
        case CHARTYPE_PERIOD:
        case CHARTYPE_UNDERSCORE:
            // Scan the ShortHand Pointer NCName
            nameOffset = currentOffset;
            currentOffset = scanNCName(data, endOffset, currentOffset);

            if (currentOffset == nameOffset) {
                //return false;
                reportError("InvalidNCNameInElementSchemeData",
                        new Object[] { data });
                return false;
            }

            if (currentOffset < endOffset) {
                ch = data.charAt(currentOffset);
            } else {
                ch = -1;
            }

            nameHandle = symbolTable.addSymbol(data.substring(
                    nameOffset, currentOffset));
            addToken(tokens, Tokens.XPTRTOKEN_ELEM_NCNAME);
            tokens.addToken(nameHandle);

            break;
        }
    }
    return true;
}
 
Example 13
Source File: XSDocumentInfo.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
XSDocumentInfo (Element schemaRoot, XSAttributeChecker attrChecker, SymbolTable symbolTable)
                throws XMLSchemaException {
    fSchemaElement = schemaRoot;
    initNamespaceSupport(schemaRoot);
    fIsChameleonSchema = false;

    fSymbolTable = symbolTable;
    fAttrChecker = attrChecker;

    if (schemaRoot != null) {
        Element root = schemaRoot;
        fSchemaAttrs = attrChecker.checkAttributes(root, true, this);
        // schemaAttrs == null means it's not an <xsd:schema> element
        // throw an exception, but we don't know the document systemId,
        // so we leave that to the caller.
        if (fSchemaAttrs == null) {
            throw new XMLSchemaException(null, null);
        }
        fAreLocalAttributesQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_AFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fAreLocalElementsQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_EFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fBlockDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_BLOCKDEFAULT]).shortValue();
        fFinalDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_FINALDEFAULT]).shortValue();
        fTargetNamespace =
            (String)fSchemaAttrs[XSAttributeChecker.ATTIDX_TARGETNAMESPACE];
        if (fTargetNamespace != null)
            fTargetNamespace = symbolTable.addSymbol(fTargetNamespace);

        fNamespaceSupportRoot = new SchemaNamespaceSupport(fNamespaceSupport);

        //set namespace support
        fValidationContext.setNamespaceSupport(fNamespaceSupport);
        fValidationContext.setSymbolTable(symbolTable);
        // pass null as the schema document, so that the namespace
        // context is not popped.

        // don't return the attribute array yet!
        //attrChecker.returnAttrArray(schemaAttrs, null);
    }
}
 
Example 14
Source File: XSDocumentInfo.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
XSDocumentInfo (Element schemaRoot, XSAttributeChecker attrChecker, SymbolTable symbolTable)
                throws XMLSchemaException {
    fSchemaElement = schemaRoot;
    initNamespaceSupport(schemaRoot);
    fIsChameleonSchema = false;

    fSymbolTable = symbolTable;
    fAttrChecker = attrChecker;

    if (schemaRoot != null) {
        Element root = schemaRoot;
        fSchemaAttrs = attrChecker.checkAttributes(root, true, this);
        // schemaAttrs == null means it's not an <xsd:schema> element
        // throw an exception, but we don't know the document systemId,
        // so we leave that to the caller.
        if (fSchemaAttrs == null) {
            throw new XMLSchemaException(null, null);
        }
        fAreLocalAttributesQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_AFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fAreLocalElementsQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_EFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fBlockDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_BLOCKDEFAULT]).shortValue();
        fFinalDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_FINALDEFAULT]).shortValue();
        fTargetNamespace =
            (String)fSchemaAttrs[XSAttributeChecker.ATTIDX_TARGETNAMESPACE];
        if (fTargetNamespace != null)
            fTargetNamespace = symbolTable.addSymbol(fTargetNamespace);

        fNamespaceSupportRoot = new SchemaNamespaceSupport(fNamespaceSupport);

        //set namespace support
        fValidationContext.setNamespaceSupport(fNamespaceSupport);
        fValidationContext.setSymbolTable(symbolTable);
        // pass null as the schema document, so that the namespace
        // context is not popped.

        // don't return the attribute array yet!
        //attrChecker.returnAttrArray(schemaAttrs, null);
    }
}
 
Example 15
Source File: XSDocumentInfo.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
XSDocumentInfo (Element schemaRoot, XSAttributeChecker attrChecker, SymbolTable symbolTable)
                throws XMLSchemaException {
    fSchemaElement = schemaRoot;
    initNamespaceSupport(schemaRoot);
    fIsChameleonSchema = false;

    fSymbolTable = symbolTable;
    fAttrChecker = attrChecker;

    if (schemaRoot != null) {
        Element root = schemaRoot;
        fSchemaAttrs = attrChecker.checkAttributes(root, true, this);
        // schemaAttrs == null means it's not an <xsd:schema> element
        // throw an exception, but we don't know the document systemId,
        // so we leave that to the caller.
        if (fSchemaAttrs == null) {
            throw new XMLSchemaException(null, null);
        }
        fAreLocalAttributesQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_AFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fAreLocalElementsQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_EFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fBlockDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_BLOCKDEFAULT]).shortValue();
        fFinalDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_FINALDEFAULT]).shortValue();
        fTargetNamespace =
            (String)fSchemaAttrs[XSAttributeChecker.ATTIDX_TARGETNAMESPACE];
        if (fTargetNamespace != null)
            fTargetNamespace = symbolTable.addSymbol(fTargetNamespace);

        fNamespaceSupportRoot = new SchemaNamespaceSupport(fNamespaceSupport);

        //set namespace support
        fValidationContext.setNamespaceSupport(fNamespaceSupport);
        fValidationContext.setSymbolTable(symbolTable);
        // pass null as the schema document, so that the namespace
        // context is not popped.

        // don't return the attribute array yet!
        //attrChecker.returnAttrArray(schemaAttrs, null);
    }
}
 
Example 16
Source File: ElementSchemePointer.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Scans the XPointer Expression
 *
 */
private boolean scanExpr(SymbolTable symbolTable, Tokens tokens,
        String data, int currentOffset, int endOffset)
        throws XNIException {

    int ch;
    int nameOffset;
    String nameHandle = null;

    while (true) {
        if (currentOffset == endOffset) {
            break;
        }

        ch = data.charAt(currentOffset);
        byte chartype = (ch >= 0x80) ? CHARTYPE_NONASCII
                : fASCIICharMap[ch];

        //
        // [1]    ElementSchemeData    ::=    (NCName ChildSequence?) | ChildSequence
        // [2]    ChildSequence    ::=    ('/' [1-9] [0-9]*)+
        //

        switch (chartype) {

        case CHARTYPE_SLASH:
            // if last character is '/', break and report an error
            if (++currentOffset == endOffset) {
                return false;
            }

            addToken(tokens, Tokens.XPTRTOKEN_ELEM_CHILD);
            ch = data.charAt(currentOffset);

            // ChildSequence    ::=    ('/' [1-9] [0-9]*)+
            int child = 0;
            while (ch >= '0' && ch <= '9') {
                child = (child * 10) + (ch - '0');
                if (++currentOffset == endOffset) {
                    break;
                }
                ch = data.charAt(currentOffset);
            }

            // An invalid child sequence character
            if (child == 0) {
                reportError("InvalidChildSequenceCharacter",
                        new Object[] { new Character((char) ch) });
                return false;
            }

            tokens.addToken(child);

            break;

        case CHARTYPE_DIGIT:
        case CHARTYPE_LETTER:
        case CHARTYPE_MINUS:
        case CHARTYPE_NONASCII:
        case CHARTYPE_OTHER:
        case CHARTYPE_PERIOD:
        case CHARTYPE_UNDERSCORE:
            // Scan the ShortHand Pointer NCName
            nameOffset = currentOffset;
            currentOffset = scanNCName(data, endOffset, currentOffset);

            if (currentOffset == nameOffset) {
                //return false;
                reportError("InvalidNCNameInElementSchemeData",
                        new Object[] { data });
                return false;
            }

            if (currentOffset < endOffset) {
                ch = data.charAt(currentOffset);
            } else {
                ch = -1;
            }

            nameHandle = symbolTable.addSymbol(data.substring(
                    nameOffset, currentOffset));
            addToken(tokens, Tokens.XPTRTOKEN_ELEM_NCNAME);
            tokens.addToken(nameHandle);

            break;
        }
    }
    return true;
}
 
Example 17
Source File: XSDocumentInfo.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
XSDocumentInfo (Element schemaRoot, XSAttributeChecker attrChecker, SymbolTable symbolTable)
                throws XMLSchemaException {
    fSchemaElement = schemaRoot;
    initNamespaceSupport(schemaRoot);
    fIsChameleonSchema = false;

    fSymbolTable = symbolTable;
    fAttrChecker = attrChecker;

    if (schemaRoot != null) {
        Element root = schemaRoot;
        fSchemaAttrs = attrChecker.checkAttributes(root, true, this);
        // schemaAttrs == null means it's not an <xsd:schema> element
        // throw an exception, but we don't know the document systemId,
        // so we leave that to the caller.
        if (fSchemaAttrs == null) {
            throw new XMLSchemaException(null, null);
        }
        fAreLocalAttributesQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_AFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fAreLocalElementsQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_EFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fBlockDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_BLOCKDEFAULT]).shortValue();
        fFinalDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_FINALDEFAULT]).shortValue();
        fTargetNamespace =
            (String)fSchemaAttrs[XSAttributeChecker.ATTIDX_TARGETNAMESPACE];
        if (fTargetNamespace != null)
            fTargetNamespace = symbolTable.addSymbol(fTargetNamespace);

        fNamespaceSupportRoot = new SchemaNamespaceSupport(fNamespaceSupport);

        //set namespace support
        fValidationContext.setNamespaceSupport(fNamespaceSupport);
        fValidationContext.setSymbolTable(symbolTable);
        // pass null as the schema document, so that the namespace
        // context is not popped.

        // don't return the attribute array yet!
        //attrChecker.returnAttrArray(schemaAttrs, null);
    }
}
 
Example 18
Source File: ElementSchemePointer.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Scans the XPointer Expression
 *
 */
private boolean scanExpr(SymbolTable symbolTable, Tokens tokens,
        String data, int currentOffset, int endOffset)
        throws XNIException {

    int ch;
    int nameOffset;
    String nameHandle = null;

    while (true) {
        if (currentOffset == endOffset) {
            break;
        }

        ch = data.charAt(currentOffset);
        byte chartype = (ch >= 0x80) ? CHARTYPE_NONASCII
                : fASCIICharMap[ch];

        //
        // [1]    ElementSchemeData    ::=    (NCName ChildSequence?) | ChildSequence
        // [2]    ChildSequence    ::=    ('/' [1-9] [0-9]*)+
        //

        switch (chartype) {

        case CHARTYPE_SLASH:
            // if last character is '/', break and report an error
            if (++currentOffset == endOffset) {
                return false;
            }

            addToken(tokens, Tokens.XPTRTOKEN_ELEM_CHILD);
            ch = data.charAt(currentOffset);

            // ChildSequence    ::=    ('/' [1-9] [0-9]*)+
            int child = 0;
            while (ch >= '0' && ch <= '9') {
                child = (child * 10) + (ch - '0');
                if (++currentOffset == endOffset) {
                    break;
                }
                ch = data.charAt(currentOffset);
            }

            // An invalid child sequence character
            if (child == 0) {
                reportError("InvalidChildSequenceCharacter",
                        new Object[] { new Character((char) ch) });
                return false;
            }

            tokens.addToken(child);

            break;

        case CHARTYPE_DIGIT:
        case CHARTYPE_LETTER:
        case CHARTYPE_MINUS:
        case CHARTYPE_NONASCII:
        case CHARTYPE_OTHER:
        case CHARTYPE_PERIOD:
        case CHARTYPE_UNDERSCORE:
            // Scan the ShortHand Pointer NCName
            nameOffset = currentOffset;
            currentOffset = scanNCName(data, endOffset, currentOffset);

            if (currentOffset == nameOffset) {
                //return false;
                reportError("InvalidNCNameInElementSchemeData",
                        new Object[] { data });
                return false;
            }

            if (currentOffset < endOffset) {
                ch = data.charAt(currentOffset);
            } else {
                ch = -1;
            }

            nameHandle = symbolTable.addSymbol(data.substring(
                    nameOffset, currentOffset));
            addToken(tokens, Tokens.XPTRTOKEN_ELEM_NCNAME);
            tokens.addToken(nameHandle);

            break;
        }
    }
    return true;
}
 
Example 19
Source File: XSDocumentInfo.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
XSDocumentInfo (Element schemaRoot, XSAttributeChecker attrChecker, SymbolTable symbolTable)
                throws XMLSchemaException {
    fSchemaElement = schemaRoot;
    initNamespaceSupport(schemaRoot);
    fIsChameleonSchema = false;

    fSymbolTable = symbolTable;
    fAttrChecker = attrChecker;

    if (schemaRoot != null) {
        Element root = schemaRoot;
        fSchemaAttrs = attrChecker.checkAttributes(root, true, this);
        // schemaAttrs == null means it's not an <xsd:schema> element
        // throw an exception, but we don't know the document systemId,
        // so we leave that to the caller.
        if (fSchemaAttrs == null) {
            throw new XMLSchemaException(null, null);
        }
        fAreLocalAttributesQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_AFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fAreLocalElementsQualified =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_EFORMDEFAULT]).intValue() == SchemaSymbols.FORM_QUALIFIED;
        fBlockDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_BLOCKDEFAULT]).shortValue();
        fFinalDefault =
            ((XInt)fSchemaAttrs[XSAttributeChecker.ATTIDX_FINALDEFAULT]).shortValue();
        fTargetNamespace =
            (String)fSchemaAttrs[XSAttributeChecker.ATTIDX_TARGETNAMESPACE];
        if (fTargetNamespace != null)
            fTargetNamespace = symbolTable.addSymbol(fTargetNamespace);

        fNamespaceSupportRoot = new SchemaNamespaceSupport(fNamespaceSupport);

        //set namespace support
        fValidationContext.setNamespaceSupport(fNamespaceSupport);
        fValidationContext.setSymbolTable(symbolTable);
        // pass null as the schema document, so that the namespace
        // context is not popped.

        // don't return the attribute array yet!
        //attrChecker.returnAttrArray(schemaAttrs, null);
    }
}
 
Example 20
Source File: ElementSchemePointer.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * Scans the XPointer Expression
 *
 */
private boolean scanExpr(SymbolTable symbolTable, Tokens tokens,
        String data, int currentOffset, int endOffset)
        throws XNIException {

    int ch;
    int nameOffset;
    String nameHandle = null;

    while (true) {
        if (currentOffset == endOffset) {
            break;
        }

        ch = data.charAt(currentOffset);
        byte chartype = (ch >= 0x80) ? CHARTYPE_NONASCII
                : fASCIICharMap[ch];

        //
        // [1]    ElementSchemeData    ::=    (NCName ChildSequence?) | ChildSequence
        // [2]    ChildSequence    ::=    ('/' [1-9] [0-9]*)+
        //

        switch (chartype) {

        case CHARTYPE_SLASH:
            // if last character is '/', break and report an error
            if (++currentOffset == endOffset) {
                return false;
            }

            addToken(tokens, Tokens.XPTRTOKEN_ELEM_CHILD);
            ch = data.charAt(currentOffset);

            // ChildSequence    ::=    ('/' [1-9] [0-9]*)+
            int child = 0;
            while (ch >= '0' && ch <= '9') {
                child = (child * 10) + (ch - '0');
                if (++currentOffset == endOffset) {
                    break;
                }
                ch = data.charAt(currentOffset);
            }

            // An invalid child sequence character
            if (child == 0) {
                reportError("InvalidChildSequenceCharacter",
                        new Object[] { new Character((char) ch) });
                return false;
            }

            tokens.addToken(child);

            break;

        case CHARTYPE_DIGIT:
        case CHARTYPE_LETTER:
        case CHARTYPE_MINUS:
        case CHARTYPE_NONASCII:
        case CHARTYPE_OTHER:
        case CHARTYPE_PERIOD:
        case CHARTYPE_UNDERSCORE:
            // Scan the ShortHand Pointer NCName
            nameOffset = currentOffset;
            currentOffset = scanNCName(data, endOffset, currentOffset);

            if (currentOffset == nameOffset) {
                //return false;
                reportError("InvalidNCNameInElementSchemeData",
                        new Object[] { data });
                return false;
            }

            if (currentOffset < endOffset) {
                ch = data.charAt(currentOffset);
            } else {
                ch = -1;
            }

            nameHandle = symbolTable.addSymbol(data.substring(
                    nameOffset, currentOffset));
            addToken(tokens, Tokens.XPTRTOKEN_ELEM_NCNAME);
            tokens.addToken(nameHandle);

            break;
        }
    }
    return true;
}