Java Code Examples for com.sun.org.apache.xerces.internal.impl.xs.SchemaSymbols#URI_SCHEMAFORSCHEMA

The following examples show how to use com.sun.org.apache.xerces.internal.impl.xs.SchemaSymbols#URI_SCHEMAFORSCHEMA . 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: XSDSimpleTypeTraverser.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private final boolean checkBuiltIn(String name, String namespace) {
    if (namespace != SchemaSymbols.URI_SCHEMAFORSCHEMA)
        return false;
    if (SchemaGrammar.SG_SchemaNS.getGlobalTypeDecl(name) != null)
        fIsBuiltIn = true;
    return fIsBuiltIn;
}
 
Example 2
Source File: SchemaDOMParser.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param attributes
 * @return
 */
private boolean hasNonSchemaAttributes(QName element, XMLAttributes attributes) {
    final int length = attributes.getLength();
    for (int i = 0; i < length; ++i) {
        String uri = attributes.getURI(i);
        if (uri != null && uri != SchemaSymbols.URI_SCHEMAFORSCHEMA &&
                uri != NamespaceContext.XMLNS_URI &&
                !(uri == NamespaceContext.XML_URI &&
                        attributes.getQName(i) == SchemaSymbols.ATT_XML_LANG && element.localpart == SchemaSymbols.ELT_SCHEMA)) {
            return true;
        }
    }
    return false;
}
 
Example 3
Source File: SchemaDOMParser.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * The end of an element.
 *
 * @param element The name of the element.
 * @param augs    Additional information that may include infoset augmentations
 *
 * @exception XNIException
 *                   Thrown by handler to signal an error.
 */
public void endElement(QName element, Augmentations augs) throws XNIException {

    // when we reach the endElement of xs:appinfo or xs:documentation,
    // change fInnerAnnotationDepth to -1
    if(fAnnotationDepth > -1) {
        if (fInnerAnnotationDepth == fDepth) {
            fInnerAnnotationDepth = -1;
            schemaDOM.endAnnotationElement(element);
            schemaDOM.endElement();
        } else if (fAnnotationDepth == fDepth) {
            fAnnotationDepth = -1;
            schemaDOM.endAnnotation(element, fCurrentAnnotationElement);
            schemaDOM.endElement();
        } else { // inside a child of annotation
            schemaDOM.endAnnotationElement(element);
        }
    } else { // not in an annotation at all
        if(element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA && fGenerateSyntheticAnnotation) {
            boolean value = fHasNonSchemaAttributes.pop();
            boolean sawann = fSawAnnotation.pop();
            if (value && !sawann) {
                String schemaPrefix = fNamespaceContext.getPrefix(SchemaSymbols.URI_SCHEMAFORSCHEMA);
                final String annRawName = (schemaPrefix.length() == 0) ? SchemaSymbols.ELT_ANNOTATION : (schemaPrefix + ':' + SchemaSymbols.ELT_ANNOTATION);
                schemaDOM.startAnnotation(annRawName, fEmptyAttr, fNamespaceContext);
                final String elemRawName = (schemaPrefix.length() == 0) ? SchemaSymbols.ELT_DOCUMENTATION : (schemaPrefix + ':' + SchemaSymbols.ELT_DOCUMENTATION);
                schemaDOM.startAnnotationElement(elemRawName, fEmptyAttr);
                schemaDOM.charactersRaw("SYNTHETIC_ANNOTATION");
                schemaDOM.endSyntheticAnnotationElement(elemRawName, false);
                schemaDOM.endSyntheticAnnotationElement(annRawName, true);
            }
        }
        schemaDOM.endElement();
    }
    fDepth--;

}
 
Example 4
Source File: XSDSimpleTypeTraverser.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
private final boolean checkBuiltIn(String name, String namespace) {
    if (namespace != SchemaSymbols.URI_SCHEMAFORSCHEMA)
        return false;
    if (SchemaGrammar.SG_SchemaNS.getGlobalTypeDecl(name) != null)
        fIsBuiltIn = true;
    return fIsBuiltIn;
}
 
Example 5
Source File: SchemaDOMParser.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The end of an element.
 *
 * @param element The name of the element.
 * @param augs    Additional information that may include infoset augmentations
 *
 * @exception XNIException
 *                   Thrown by handler to signal an error.
 */
public void endElement(QName element, Augmentations augs) throws XNIException {

    // when we reach the endElement of xs:appinfo or xs:documentation,
    // change fInnerAnnotationDepth to -1
    if(fAnnotationDepth > -1) {
        if (fInnerAnnotationDepth == fDepth) {
            fInnerAnnotationDepth = -1;
            schemaDOM.endAnnotationElement(element);
            schemaDOM.endElement();
        } else if (fAnnotationDepth == fDepth) {
            fAnnotationDepth = -1;
            schemaDOM.endAnnotation(element, fCurrentAnnotationElement);
            schemaDOM.endElement();
        } else { // inside a child of annotation
            schemaDOM.endAnnotationElement(element);
        }
    } else { // not in an annotation at all
        if(element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA && fGenerateSyntheticAnnotation) {
            boolean value = fHasNonSchemaAttributes.pop();
            boolean sawann = fSawAnnotation.pop();
            if (value && !sawann) {
                String schemaPrefix = fNamespaceContext.getPrefix(SchemaSymbols.URI_SCHEMAFORSCHEMA);
                final String annRawName = (schemaPrefix.length() == 0) ? SchemaSymbols.ELT_ANNOTATION : (schemaPrefix + ':' + SchemaSymbols.ELT_ANNOTATION);
                schemaDOM.startAnnotation(annRawName, fEmptyAttr, fNamespaceContext);
                final String elemRawName = (schemaPrefix.length() == 0) ? SchemaSymbols.ELT_DOCUMENTATION : (schemaPrefix + ':' + SchemaSymbols.ELT_DOCUMENTATION);
                schemaDOM.startAnnotationElement(elemRawName, fEmptyAttr);
                schemaDOM.charactersRaw("SYNTHETIC_ANNOTATION");
                schemaDOM.endSyntheticAnnotationElement(elemRawName, false);
                schemaDOM.endSyntheticAnnotationElement(annRawName, true);
            }
        }
        schemaDOM.endElement();
    }
    fDepth--;

}
 
Example 6
Source File: SchemaDOMParser.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param attributes
 * @return
 */
private boolean hasNonSchemaAttributes(QName element, XMLAttributes attributes) {
    final int length = attributes.getLength();
    for (int i = 0; i < length; ++i) {
        String uri = attributes.getURI(i);
        if (uri != null && uri != SchemaSymbols.URI_SCHEMAFORSCHEMA &&
                uri != NamespaceContext.XMLNS_URI &&
                !(uri == NamespaceContext.XML_URI &&
                        attributes.getQName(i) == SchemaSymbols.ATT_XML_LANG && element.localpart == SchemaSymbols.ELT_SCHEMA)) {
            return true;
        }
    }
    return false;
}
 
Example 7
Source File: SchemaDOMParser.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The end of an element.
 *
 * @param element The name of the element.
 * @param augs    Additional information that may include infoset augmentations
 *
 * @exception XNIException
 *                   Thrown by handler to signal an error.
 */
public void endElement(QName element, Augmentations augs) throws XNIException {

    // when we reach the endElement of xs:appinfo or xs:documentation,
    // change fInnerAnnotationDepth to -1
    if(fAnnotationDepth > -1) {
        if (fInnerAnnotationDepth == fDepth) {
            fInnerAnnotationDepth = -1;
            schemaDOM.endAnnotationElement(element);
            schemaDOM.endElement();
        } else if (fAnnotationDepth == fDepth) {
            fAnnotationDepth = -1;
            schemaDOM.endAnnotation(element, fCurrentAnnotationElement);
            schemaDOM.endElement();
        } else { // inside a child of annotation
            schemaDOM.endAnnotationElement(element);
        }
    } else { // not in an annotation at all
        if(element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA && fGenerateSyntheticAnnotation) {
            boolean value = fHasNonSchemaAttributes.pop();
            boolean sawann = fSawAnnotation.pop();
            if (value && !sawann) {
                String schemaPrefix = fNamespaceContext.getPrefix(SchemaSymbols.URI_SCHEMAFORSCHEMA);
                final String annRawName = (schemaPrefix.length() == 0) ? SchemaSymbols.ELT_ANNOTATION : (schemaPrefix + ':' + SchemaSymbols.ELT_ANNOTATION);
                schemaDOM.startAnnotation(annRawName, fEmptyAttr, fNamespaceContext);
                final String elemRawName = (schemaPrefix.length() == 0) ? SchemaSymbols.ELT_DOCUMENTATION : (schemaPrefix + ':' + SchemaSymbols.ELT_DOCUMENTATION);
                schemaDOM.startAnnotationElement(elemRawName, fEmptyAttr);
                schemaDOM.charactersRaw("SYNTHETIC_ANNOTATION");
                schemaDOM.endSyntheticAnnotationElement(elemRawName, false);
                schemaDOM.endSyntheticAnnotationElement(annRawName, true);
            }
        }
        schemaDOM.endElement();
    }
    fDepth--;

}
 
Example 8
Source File: SchemaDOMParser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param attributes
 * @return
 */
private boolean hasNonSchemaAttributes(QName element, XMLAttributes attributes) {
    final int length = attributes.getLength();
    for (int i = 0; i < length; ++i) {
        String uri = attributes.getURI(i);
        if (uri != null && uri != SchemaSymbols.URI_SCHEMAFORSCHEMA &&
                uri != NamespaceContext.XMLNS_URI &&
                !(uri == NamespaceContext.XML_URI &&
                        attributes.getQName(i) == SchemaSymbols.ATT_XML_LANG && element.localpart == SchemaSymbols.ELT_SCHEMA)) {
            return true;
        }
    }
    return false;
}
 
Example 9
Source File: XSDSimpleTypeTraverser.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private final boolean checkBuiltIn(String name, String namespace) {
    if (namespace != SchemaSymbols.URI_SCHEMAFORSCHEMA)
        return false;
    if (SchemaGrammar.SG_SchemaNS.getGlobalTypeDecl(name) != null)
        fIsBuiltIn = true;
    return fIsBuiltIn;
}
 
Example 10
Source File: SchemaDOMParser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The end of an element.
 *
 * @param element The name of the element.
 * @param augs    Additional information that may include infoset augmentations
 *
 * @exception XNIException
 *                   Thrown by handler to signal an error.
 */
public void endElement(QName element, Augmentations augs) throws XNIException {

    // when we reach the endElement of xs:appinfo or xs:documentation,
    // change fInnerAnnotationDepth to -1
    if(fAnnotationDepth > -1) {
        if (fInnerAnnotationDepth == fDepth) {
            fInnerAnnotationDepth = -1;
            schemaDOM.endAnnotationElement(element);
            schemaDOM.endElement();
        } else if (fAnnotationDepth == fDepth) {
            fAnnotationDepth = -1;
            schemaDOM.endAnnotation(element, fCurrentAnnotationElement);
            schemaDOM.endElement();
        } else { // inside a child of annotation
            schemaDOM.endAnnotationElement(element);
        }
    } else { // not in an annotation at all
        if(element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA && fGenerateSyntheticAnnotation) {
            boolean value = fHasNonSchemaAttributes.pop();
            boolean sawann = fSawAnnotation.pop();
            if (value && !sawann) {
                String schemaPrefix = fNamespaceContext.getPrefix(SchemaSymbols.URI_SCHEMAFORSCHEMA);
                final String annRawName = (schemaPrefix.length() == 0) ? SchemaSymbols.ELT_ANNOTATION : (schemaPrefix + ':' + SchemaSymbols.ELT_ANNOTATION);
                schemaDOM.startAnnotation(annRawName, fEmptyAttr, fNamespaceContext);
                final String elemRawName = (schemaPrefix.length() == 0) ? SchemaSymbols.ELT_DOCUMENTATION : (schemaPrefix + ':' + SchemaSymbols.ELT_DOCUMENTATION);
                schemaDOM.startAnnotationElement(elemRawName, fEmptyAttr);
                schemaDOM.charactersRaw("SYNTHETIC_ANNOTATION");
                schemaDOM.endSyntheticAnnotationElement(elemRawName, false);
                schemaDOM.endSyntheticAnnotationElement(annRawName, true);
            }
        }
        schemaDOM.endElement();
    }
    fDepth--;

}
 
Example 11
Source File: SchemaDOMParser.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The end of an element.
 *
 * @param element The name of the element.
 * @param augs    Additional information that may include infoset augmentations
 *
 * @exception XNIException
 *                   Thrown by handler to signal an error.
 */
public void endElement(QName element, Augmentations augs) throws XNIException {

    // when we reach the endElement of xs:appinfo or xs:documentation,
    // change fInnerAnnotationDepth to -1
    if(fAnnotationDepth > -1) {
        if (fInnerAnnotationDepth == fDepth) {
            fInnerAnnotationDepth = -1;
            schemaDOM.endAnnotationElement(element);
            schemaDOM.endElement();
        } else if (fAnnotationDepth == fDepth) {
            fAnnotationDepth = -1;
            schemaDOM.endAnnotation(element, fCurrentAnnotationElement);
            schemaDOM.endElement();
        } else { // inside a child of annotation
            schemaDOM.endAnnotationElement(element);
        }
    } else { // not in an annotation at all
        if(element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA && fGenerateSyntheticAnnotation) {
            boolean value = fHasNonSchemaAttributes.pop();
            boolean sawann = fSawAnnotation.pop();
            if (value && !sawann) {
                String schemaPrefix = fNamespaceContext.getPrefix(SchemaSymbols.URI_SCHEMAFORSCHEMA);
                final String annRawName = (schemaPrefix.length() == 0) ? SchemaSymbols.ELT_ANNOTATION : (schemaPrefix + ':' + SchemaSymbols.ELT_ANNOTATION);
                schemaDOM.startAnnotation(annRawName, fEmptyAttr, fNamespaceContext);
                final String elemRawName = (schemaPrefix.length() == 0) ? SchemaSymbols.ELT_DOCUMENTATION : (schemaPrefix + ':' + SchemaSymbols.ELT_DOCUMENTATION);
                schemaDOM.startAnnotationElement(elemRawName, fEmptyAttr);
                schemaDOM.charactersRaw("SYNTHETIC_ANNOTATION");
                schemaDOM.endSyntheticAnnotationElement(elemRawName, false);
                schemaDOM.endSyntheticAnnotationElement(annRawName, true);
            }
        }
        schemaDOM.endElement();
    }
    fDepth--;

}
 
Example 12
Source File: XSDSimpleTypeTraverser.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private final boolean checkBuiltIn(String name, String namespace) {
    if (namespace != SchemaSymbols.URI_SCHEMAFORSCHEMA)
        return false;
    if (SchemaGrammar.SG_SchemaNS.getGlobalTypeDecl(name) != null)
        fIsBuiltIn = true;
    return fIsBuiltIn;
}
 
Example 13
Source File: SchemaDOMParser.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * An empty element.
 *
 * @param element    The name of the element.
 * @param attributes The element attributes.
 * @param augs       Additional information that may include infoset augmentations
 *
 * @exception XNIException
 *                   Thrown by handler to signal an error.
 */
public void emptyElement(QName element, XMLAttributes attributes, Augmentations augs)
throws XNIException {

    if (fGenerateSyntheticAnnotation && fAnnotationDepth == -1 &&
            element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA && element.localpart != SchemaSymbols.ELT_ANNOTATION && hasNonSchemaAttributes(element, attributes)) {

        schemaDOM.startElement(element, attributes,
                fLocator.getLineNumber(),
                fLocator.getColumnNumber(),
                fLocator.getCharacterOffset());

        attributes.removeAllAttributes();
        String schemaPrefix = fNamespaceContext.getPrefix(SchemaSymbols.URI_SCHEMAFORSCHEMA);
        final String annRawName = (schemaPrefix.length() == 0) ? SchemaSymbols.ELT_ANNOTATION : (schemaPrefix + ':' + SchemaSymbols.ELT_ANNOTATION);
        schemaDOM.startAnnotation(annRawName, attributes, fNamespaceContext);
        final String elemRawName = (schemaPrefix.length() == 0) ? SchemaSymbols.ELT_DOCUMENTATION : (schemaPrefix + ':' + SchemaSymbols.ELT_DOCUMENTATION);
        schemaDOM.startAnnotationElement(elemRawName, attributes);
        schemaDOM.charactersRaw("SYNTHETIC_ANNOTATION");
        schemaDOM.endSyntheticAnnotationElement(elemRawName, false);
        schemaDOM.endSyntheticAnnotationElement(annRawName, true);

        schemaDOM.endElement();

        return;
    }
    // the order of events that occurs here is:
    //   schemaDOM.startAnnotation/startAnnotationElement (if applicable)
    //   schemaDOM.emptyElement  (basically the same as startElement then endElement)
    //   schemaDOM.endAnnotationElement (if applicable)
    // the order of events that would occur if this was <element></element>:
    //   schemaDOM.startAnnotation/startAnnotationElement (if applicable)
    //   schemaDOM.startElement
    //   schemaDOM.endAnnotationElement (if applicable)
    //   schemaDOM.endElementElement
    // Thus, we can see that the order of events isn't the same.  However, it doesn't
    // seem to matter.  -- PJM
    if (fAnnotationDepth == -1) {
        // this is messed up, but a case to consider:
        if (element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA &&
                element.localpart == SchemaSymbols.ELT_ANNOTATION) {
            schemaDOM.startAnnotation(element, attributes, fNamespaceContext);
        }
    }
    else {
        schemaDOM.startAnnotationElement(element, attributes);
    }

    ElementImpl newElem = schemaDOM.emptyElement(element, attributes,
            fLocator.getLineNumber(),
            fLocator.getColumnNumber(),
            fLocator.getCharacterOffset());

    if (fAnnotationDepth == -1) {
        // this is messed up, but a case to consider:
        if (element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA &&
                element.localpart == SchemaSymbols.ELT_ANNOTATION) {
            schemaDOM.endAnnotation(element, newElem);
        }
    }
    else {
        schemaDOM.endAnnotationElement(element);
    }
}
 
Example 14
Source File: SchemaDOMParser.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * The start of an element.
 *
 * @param element    The name of the element.
 * @param attributes The element attributes.
 * @param augs       Additional information that may include infoset augmentations
 *
 * @exception XNIException
 *                   Thrown by handler to signal an error.
 */
public void startElement(QName element, XMLAttributes attributes, Augmentations augs)
throws XNIException {

    fDepth++;
    // while it is true that non-whitespace character data
    // may only occur in appInfo or documentation
    // elements, it's certainly legal for comments and PI's to
    // occur as children of annotation; we need
    // to account for these here.
    if (fAnnotationDepth == -1) {
        if (element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA &&
                element.localpart == SchemaSymbols.ELT_ANNOTATION) {
            if (fGenerateSyntheticAnnotation) {
                if (fSawAnnotation.size() > 0) {
                    fSawAnnotation.pop();
                }
                fSawAnnotation.push(true);
            }
            fAnnotationDepth = fDepth;
            schemaDOM.startAnnotation(element, attributes, fNamespaceContext);
            fCurrentAnnotationElement = schemaDOM.startElement(element, attributes,
                    fLocator.getLineNumber(),
                    fLocator.getColumnNumber(),
                    fLocator.getCharacterOffset());
            return;
        }
        else if (element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA && fGenerateSyntheticAnnotation) {
            fSawAnnotation.push(false);
            fHasNonSchemaAttributes.push(hasNonSchemaAttributes(element, attributes));
        }
    }
    else if (fDepth == fAnnotationDepth + 1) {
        fInnerAnnotationDepth = fDepth;
        schemaDOM.startAnnotationElement(element, attributes);
    }
    else {
        schemaDOM.startAnnotationElement(element, attributes);
        // avoid falling through; don't call startElement in this case
        return;
    }
    schemaDOM.startElement(element, attributes,
            fLocator.getLineNumber(),
            fLocator.getColumnNumber(),
            fLocator.getCharacterOffset());

}
 
Example 15
Source File: SchemaDOMParser.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * An empty element.
 *
 * @param element    The name of the element.
 * @param attributes The element attributes.
 * @param augs       Additional information that may include infoset augmentations
 *
 * @exception XNIException
 *                   Thrown by handler to signal an error.
 */
public void emptyElement(QName element, XMLAttributes attributes, Augmentations augs)
throws XNIException {

    if (fGenerateSyntheticAnnotation && fAnnotationDepth == -1 &&
            element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA && element.localpart != SchemaSymbols.ELT_ANNOTATION && hasNonSchemaAttributes(element, attributes)) {

        schemaDOM.startElement(element, attributes,
                fLocator.getLineNumber(),
                fLocator.getColumnNumber(),
                fLocator.getCharacterOffset());

        attributes.removeAllAttributes();
        String schemaPrefix = fNamespaceContext.getPrefix(SchemaSymbols.URI_SCHEMAFORSCHEMA);
        final String annRawName = (schemaPrefix.length() == 0) ? SchemaSymbols.ELT_ANNOTATION : (schemaPrefix + ':' + SchemaSymbols.ELT_ANNOTATION);
        schemaDOM.startAnnotation(annRawName, attributes, fNamespaceContext);
        final String elemRawName = (schemaPrefix.length() == 0) ? SchemaSymbols.ELT_DOCUMENTATION : (schemaPrefix + ':' + SchemaSymbols.ELT_DOCUMENTATION);
        schemaDOM.startAnnotationElement(elemRawName, attributes);
        schemaDOM.charactersRaw("SYNTHETIC_ANNOTATION");
        schemaDOM.endSyntheticAnnotationElement(elemRawName, false);
        schemaDOM.endSyntheticAnnotationElement(annRawName, true);

        schemaDOM.endElement();

        return;
    }
    // the order of events that occurs here is:
    //   schemaDOM.startAnnotation/startAnnotationElement (if applicable)
    //   schemaDOM.emptyElement  (basically the same as startElement then endElement)
    //   schemaDOM.endAnnotationElement (if applicable)
    // the order of events that would occur if this was <element></element>:
    //   schemaDOM.startAnnotation/startAnnotationElement (if applicable)
    //   schemaDOM.startElement
    //   schemaDOM.endAnnotationElement (if applicable)
    //   schemaDOM.endElementElement
    // Thus, we can see that the order of events isn't the same.  However, it doesn't
    // seem to matter.  -- PJM
    if (fAnnotationDepth == -1) {
        // this is messed up, but a case to consider:
        if (element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA &&
                element.localpart == SchemaSymbols.ELT_ANNOTATION) {
            schemaDOM.startAnnotation(element, attributes, fNamespaceContext);
        }
    }
    else {
        schemaDOM.startAnnotationElement(element, attributes);
    }

    ElementImpl newElem = schemaDOM.emptyElement(element, attributes,
            fLocator.getLineNumber(),
            fLocator.getColumnNumber(),
            fLocator.getCharacterOffset());

    if (fAnnotationDepth == -1) {
        // this is messed up, but a case to consider:
        if (element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA &&
                element.localpart == SchemaSymbols.ELT_ANNOTATION) {
            schemaDOM.endAnnotation(element, newElem);
        }
    }
    else {
        schemaDOM.endAnnotationElement(element);
    }
}
 
Example 16
Source File: SchemaDOMParser.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * The start of an element.
 *
 * @param element    The name of the element.
 * @param attributes The element attributes.
 * @param augs       Additional information that may include infoset augmentations
 *
 * @exception XNIException
 *                   Thrown by handler to signal an error.
 */
public void startElement(QName element, XMLAttributes attributes, Augmentations augs)
throws XNIException {

    fDepth++;
    // while it is true that non-whitespace character data
    // may only occur in appInfo or documentation
    // elements, it's certainly legal for comments and PI's to
    // occur as children of annotation; we need
    // to account for these here.
    if (fAnnotationDepth == -1) {
        if (element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA &&
                element.localpart == SchemaSymbols.ELT_ANNOTATION) {
            if (fGenerateSyntheticAnnotation) {
                if (fSawAnnotation.size() > 0) {
                    fSawAnnotation.pop();
                }
                fSawAnnotation.push(true);
            }
            fAnnotationDepth = fDepth;
            schemaDOM.startAnnotation(element, attributes, fNamespaceContext);
            fCurrentAnnotationElement = schemaDOM.startElement(element, attributes,
                    fLocator.getLineNumber(),
                    fLocator.getColumnNumber(),
                    fLocator.getCharacterOffset());
            return;
        }
        else if (element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA && fGenerateSyntheticAnnotation) {
            fSawAnnotation.push(false);
            fHasNonSchemaAttributes.push(hasNonSchemaAttributes(element, attributes));
        }
    }
    else if (fDepth == fAnnotationDepth + 1) {
        fInnerAnnotationDepth = fDepth;
        schemaDOM.startAnnotationElement(element, attributes);
    }
    else {
        schemaDOM.startAnnotationElement(element, attributes);
        // avoid falling through; don't call startElement in this case
        return;
    }
    schemaDOM.startElement(element, attributes,
            fLocator.getLineNumber(),
            fLocator.getColumnNumber(),
            fLocator.getCharacterOffset());

}
 
Example 17
Source File: SchemaDOMParser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * An empty element.
 *
 * @param element    The name of the element.
 * @param attributes The element attributes.
 * @param augs       Additional information that may include infoset augmentations
 *
 * @exception XNIException
 *                   Thrown by handler to signal an error.
 */
public void emptyElement(QName element, XMLAttributes attributes, Augmentations augs)
throws XNIException {

    if (fGenerateSyntheticAnnotation && fAnnotationDepth == -1 &&
            element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA && element.localpart != SchemaSymbols.ELT_ANNOTATION && hasNonSchemaAttributes(element, attributes)) {

        schemaDOM.startElement(element, attributes,
                fLocator.getLineNumber(),
                fLocator.getColumnNumber(),
                fLocator.getCharacterOffset());

        attributes.removeAllAttributes();
        String schemaPrefix = fNamespaceContext.getPrefix(SchemaSymbols.URI_SCHEMAFORSCHEMA);
        final String annRawName = (schemaPrefix.length() == 0) ? SchemaSymbols.ELT_ANNOTATION : (schemaPrefix + ':' + SchemaSymbols.ELT_ANNOTATION);
        schemaDOM.startAnnotation(annRawName, attributes, fNamespaceContext);
        final String elemRawName = (schemaPrefix.length() == 0) ? SchemaSymbols.ELT_DOCUMENTATION : (schemaPrefix + ':' + SchemaSymbols.ELT_DOCUMENTATION);
        schemaDOM.startAnnotationElement(elemRawName, attributes);
        schemaDOM.charactersRaw("SYNTHETIC_ANNOTATION");
        schemaDOM.endSyntheticAnnotationElement(elemRawName, false);
        schemaDOM.endSyntheticAnnotationElement(annRawName, true);

        schemaDOM.endElement();

        return;
    }
    // the order of events that occurs here is:
    //   schemaDOM.startAnnotation/startAnnotationElement (if applicable)
    //   schemaDOM.emptyElement  (basically the same as startElement then endElement)
    //   schemaDOM.endAnnotationElement (if applicable)
    // the order of events that would occur if this was <element></element>:
    //   schemaDOM.startAnnotation/startAnnotationElement (if applicable)
    //   schemaDOM.startElement
    //   schemaDOM.endAnnotationElement (if applicable)
    //   schemaDOM.endElementElement
    // Thus, we can see that the order of events isn't the same.  However, it doesn't
    // seem to matter.  -- PJM
    if (fAnnotationDepth == -1) {
        // this is messed up, but a case to consider:
        if (element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA &&
                element.localpart == SchemaSymbols.ELT_ANNOTATION) {
            schemaDOM.startAnnotation(element, attributes, fNamespaceContext);
        }
    }
    else {
        schemaDOM.startAnnotationElement(element, attributes);
    }

    ElementImpl newElem = schemaDOM.emptyElement(element, attributes,
            fLocator.getLineNumber(),
            fLocator.getColumnNumber(),
            fLocator.getCharacterOffset());

    if (fAnnotationDepth == -1) {
        // this is messed up, but a case to consider:
        if (element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA &&
                element.localpart == SchemaSymbols.ELT_ANNOTATION) {
            schemaDOM.endAnnotation(element, newElem);
        }
    }
    else {
        schemaDOM.endAnnotationElement(element);
    }
}
 
Example 18
Source File: SchemaDOMParser.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * An empty element.
 *
 * @param element    The name of the element.
 * @param attributes The element attributes.
 * @param augs       Additional information that may include infoset augmentations
 *
 * @exception XNIException
 *                   Thrown by handler to signal an error.
 */
public void emptyElement(QName element, XMLAttributes attributes, Augmentations augs)
throws XNIException {

    if (fGenerateSyntheticAnnotation && fAnnotationDepth == -1 &&
            element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA && element.localpart != SchemaSymbols.ELT_ANNOTATION && hasNonSchemaAttributes(element, attributes)) {

        schemaDOM.startElement(element, attributes,
                fLocator.getLineNumber(),
                fLocator.getColumnNumber(),
                fLocator.getCharacterOffset());

        attributes.removeAllAttributes();
        String schemaPrefix = fNamespaceContext.getPrefix(SchemaSymbols.URI_SCHEMAFORSCHEMA);
        final String annRawName = (schemaPrefix.length() == 0) ? SchemaSymbols.ELT_ANNOTATION : (schemaPrefix + ':' + SchemaSymbols.ELT_ANNOTATION);
        schemaDOM.startAnnotation(annRawName, attributes, fNamespaceContext);
        final String elemRawName = (schemaPrefix.length() == 0) ? SchemaSymbols.ELT_DOCUMENTATION : (schemaPrefix + ':' + SchemaSymbols.ELT_DOCUMENTATION);
        schemaDOM.startAnnotationElement(elemRawName, attributes);
        schemaDOM.charactersRaw("SYNTHETIC_ANNOTATION");
        schemaDOM.endSyntheticAnnotationElement(elemRawName, false);
        schemaDOM.endSyntheticAnnotationElement(annRawName, true);

        schemaDOM.endElement();

        return;
    }
    // the order of events that occurs here is:
    //   schemaDOM.startAnnotation/startAnnotationElement (if applicable)
    //   schemaDOM.emptyElement  (basically the same as startElement then endElement)
    //   schemaDOM.endAnnotationElement (if applicable)
    // the order of events that would occur if this was <element></element>:
    //   schemaDOM.startAnnotation/startAnnotationElement (if applicable)
    //   schemaDOM.startElement
    //   schemaDOM.endAnnotationElement (if applicable)
    //   schemaDOM.endElementElement
    // Thus, we can see that the order of events isn't the same.  However, it doesn't
    // seem to matter.  -- PJM
    if (fAnnotationDepth == -1) {
        // this is messed up, but a case to consider:
        if (element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA &&
                element.localpart == SchemaSymbols.ELT_ANNOTATION) {
            schemaDOM.startAnnotation(element, attributes, fNamespaceContext);
        }
    }
    else {
        schemaDOM.startAnnotationElement(element, attributes);
    }

    ElementImpl newElem = schemaDOM.emptyElement(element, attributes,
            fLocator.getLineNumber(),
            fLocator.getColumnNumber(),
            fLocator.getCharacterOffset());

    if (fAnnotationDepth == -1) {
        // this is messed up, but a case to consider:
        if (element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA &&
                element.localpart == SchemaSymbols.ELT_ANNOTATION) {
            schemaDOM.endAnnotation(element, newElem);
        }
    }
    else {
        schemaDOM.endAnnotationElement(element);
    }
}
 
Example 19
Source File: SchemaDOMParser.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * An empty element.
 *
 * @param element    The name of the element.
 * @param attributes The element attributes.
 * @param augs       Additional information that may include infoset augmentations
 *
 * @exception XNIException
 *                   Thrown by handler to signal an error.
 */
public void emptyElement(QName element, XMLAttributes attributes, Augmentations augs)
throws XNIException {

    if (fGenerateSyntheticAnnotation && fAnnotationDepth == -1 &&
            element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA && element.localpart != SchemaSymbols.ELT_ANNOTATION && hasNonSchemaAttributes(element, attributes)) {

        schemaDOM.startElement(element, attributes,
                fLocator.getLineNumber(),
                fLocator.getColumnNumber(),
                fLocator.getCharacterOffset());

        attributes.removeAllAttributes();
        String schemaPrefix = fNamespaceContext.getPrefix(SchemaSymbols.URI_SCHEMAFORSCHEMA);
        final String annRawName = (schemaPrefix.length() == 0) ? SchemaSymbols.ELT_ANNOTATION : (schemaPrefix + ':' + SchemaSymbols.ELT_ANNOTATION);
        schemaDOM.startAnnotation(annRawName, attributes, fNamespaceContext);
        final String elemRawName = (schemaPrefix.length() == 0) ? SchemaSymbols.ELT_DOCUMENTATION : (schemaPrefix + ':' + SchemaSymbols.ELT_DOCUMENTATION);
        schemaDOM.startAnnotationElement(elemRawName, attributes);
        schemaDOM.charactersRaw("SYNTHETIC_ANNOTATION");
        schemaDOM.endSyntheticAnnotationElement(elemRawName, false);
        schemaDOM.endSyntheticAnnotationElement(annRawName, true);

        schemaDOM.endElement();

        return;
    }
    // the order of events that occurs here is:
    //   schemaDOM.startAnnotation/startAnnotationElement (if applicable)
    //   schemaDOM.emptyElement  (basically the same as startElement then endElement)
    //   schemaDOM.endAnnotationElement (if applicable)
    // the order of events that would occur if this was <element></element>:
    //   schemaDOM.startAnnotation/startAnnotationElement (if applicable)
    //   schemaDOM.startElement
    //   schemaDOM.endAnnotationElement (if applicable)
    //   schemaDOM.endElementElement
    // Thus, we can see that the order of events isn't the same.  However, it doesn't
    // seem to matter.  -- PJM
    if (fAnnotationDepth == -1) {
        // this is messed up, but a case to consider:
        if (element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA &&
                element.localpart == SchemaSymbols.ELT_ANNOTATION) {
            schemaDOM.startAnnotation(element, attributes, fNamespaceContext);
        }
    }
    else {
        schemaDOM.startAnnotationElement(element, attributes);
    }

    ElementImpl newElem = schemaDOM.emptyElement(element, attributes,
            fLocator.getLineNumber(),
            fLocator.getColumnNumber(),
            fLocator.getCharacterOffset());

    if (fAnnotationDepth == -1) {
        // this is messed up, but a case to consider:
        if (element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA &&
                element.localpart == SchemaSymbols.ELT_ANNOTATION) {
            schemaDOM.endAnnotation(element, newElem);
        }
    }
    else {
        schemaDOM.endAnnotationElement(element);
    }
}
 
Example 20
Source File: SchemaDOMParser.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * The start of an element.
 *
 * @param element    The name of the element.
 * @param attributes The element attributes.
 * @param augs       Additional information that may include infoset augmentations
 *
 * @exception XNIException
 *                   Thrown by handler to signal an error.
 */
public void startElement(QName element, XMLAttributes attributes, Augmentations augs)
throws XNIException {

    fDepth++;
    // while it is true that non-whitespace character data
    // may only occur in appInfo or documentation
    // elements, it's certainly legal for comments and PI's to
    // occur as children of annotation; we need
    // to account for these here.
    if (fAnnotationDepth == -1) {
        if (element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA &&
                element.localpart == SchemaSymbols.ELT_ANNOTATION) {
            if (fGenerateSyntheticAnnotation) {
                if (fSawAnnotation.size() > 0) {
                    fSawAnnotation.pop();
                }
                fSawAnnotation.push(true);
            }
            fAnnotationDepth = fDepth;
            schemaDOM.startAnnotation(element, attributes, fNamespaceContext);
            fCurrentAnnotationElement = schemaDOM.startElement(element, attributes,
                    fLocator.getLineNumber(),
                    fLocator.getColumnNumber(),
                    fLocator.getCharacterOffset());
            return;
        }
        else if (element.uri == SchemaSymbols.URI_SCHEMAFORSCHEMA && fGenerateSyntheticAnnotation) {
            fSawAnnotation.push(false);
            fHasNonSchemaAttributes.push(hasNonSchemaAttributes(element, attributes));
        }
    }
    else if (fDepth == fAnnotationDepth + 1) {
        fInnerAnnotationDepth = fDepth;
        schemaDOM.startAnnotationElement(element, attributes);
    }
    else {
        schemaDOM.startAnnotationElement(element, attributes);
        // avoid falling through; don't call startElement in this case
        return;
    }
    schemaDOM.startElement(element, attributes,
            fLocator.getLineNumber(),
            fLocator.getColumnNumber(),
            fLocator.getCharacterOffset());

}