Java Code Examples for com.sun.org.apache.xerces.internal.util.DOMUtil#getLocalName()

The following examples show how to use com.sun.org.apache.xerces.internal.util.DOMUtil#getLocalName() . 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: XSDHandler.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private int changeRedefineGroup(String originalQName, String elementSought,
        String newName, Element curr, XSDocumentInfo schemaDoc) {
    int result = 0;
    for (Element child = DOMUtil.getFirstChildElement(curr);
    child != null; child = DOMUtil.getNextSiblingElement(child)) {
        String name = DOMUtil.getLocalName(child);
        if (!name.equals(elementSought))
            result += changeRedefineGroup(originalQName, elementSought, newName, child, schemaDoc);
        else {
            String ref = child.getAttribute( SchemaSymbols.ATT_REF );
            if (ref.length() != 0) {
                String processedRef = findQName(ref, schemaDoc);
                if (originalQName.equals(processedRef)) {
                    String prefix = XMLSymbols.EMPTY_STRING;
                    int colonptr = ref.indexOf(":");
                    if (colonptr > 0) {
                        prefix = ref.substring(0,colonptr);
                        child.setAttribute(SchemaSymbols.ATT_REF, prefix + ":" + newName);
                    }
                    else
                        child.setAttribute(SchemaSymbols.ATT_REF, newName);
                    result++;
                    if (elementSought.equals(SchemaSymbols.ELT_GROUP)) {
                        String minOccurs = child.getAttribute( SchemaSymbols.ATT_MINOCCURS );
                        String maxOccurs = child.getAttribute( SchemaSymbols.ATT_MAXOCCURS );
                        if (!((maxOccurs.length() == 0 || maxOccurs.equals("1"))
                                && (minOccurs.length() == 0 || minOccurs.equals("1")))) {
                            reportSchemaError("src-redefine.6.1.2", new Object [] {ref}, child);
                        }
                    }
                }
            } // if ref was null some other stage of processing will flag the error
        }
    }
    return result;
}
 
Example 2
Source File: XSDComplexTypeTraverser.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
private boolean isAttrOrAttrGroup(Element e) {
    String elementName = DOMUtil.getLocalName(e);

    if (elementName.equals(SchemaSymbols.ELT_ATTRIBUTE) ||
            elementName.equals(SchemaSymbols.ELT_ATTRIBUTEGROUP) ||
            elementName.equals(SchemaSymbols.ELT_ANYATTRIBUTE))
        return true;
    else
        return false;
}
 
Example 3
Source File: XSDHandler.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private int changeRedefineGroup(String originalQName, String elementSought,
        String newName, Element curr, XSDocumentInfo schemaDoc) {
    int result = 0;
    for (Element child = DOMUtil.getFirstChildElement(curr);
    child != null; child = DOMUtil.getNextSiblingElement(child)) {
        String name = DOMUtil.getLocalName(child);
        if (!name.equals(elementSought))
            result += changeRedefineGroup(originalQName, elementSought, newName, child, schemaDoc);
        else {
            String ref = child.getAttribute( SchemaSymbols.ATT_REF );
            if (ref.length() != 0) {
                String processedRef = findQName(ref, schemaDoc);
                if (originalQName.equals(processedRef)) {
                    String prefix = XMLSymbols.EMPTY_STRING;
                    int colonptr = ref.indexOf(":");
                    if (colonptr > 0) {
                        prefix = ref.substring(0,colonptr);
                        child.setAttribute(SchemaSymbols.ATT_REF, prefix + ":" + newName);
                    }
                    else
                        child.setAttribute(SchemaSymbols.ATT_REF, newName);
                    result++;
                    if (elementSought.equals(SchemaSymbols.ELT_GROUP)) {
                        String minOccurs = child.getAttribute( SchemaSymbols.ATT_MINOCCURS );
                        String maxOccurs = child.getAttribute( SchemaSymbols.ATT_MAXOCCURS );
                        if (!((maxOccurs.length() == 0 || maxOccurs.equals("1"))
                                && (minOccurs.length() == 0 || minOccurs.equals("1")))) {
                            reportSchemaError("src-redefine.6.1.2", new Object [] {ref}, child);
                        }
                    }
                }
            } // if ref was null some other stage of processing will flag the error
        }
    }
    return result;
}
 
Example 4
Source File: XSDComplexTypeTraverser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private boolean isAttrOrAttrGroup(Element e) {
    String elementName = DOMUtil.getLocalName(e);

    if (elementName.equals(SchemaSymbols.ELT_ATTRIBUTE) ||
            elementName.equals(SchemaSymbols.ELT_ATTRIBUTEGROUP) ||
            elementName.equals(SchemaSymbols.ELT_ANYATTRIBUTE))
        return true;
    else
        return false;
}
 
Example 5
Source File: XSDHandler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private int changeRedefineGroup(String originalQName, String elementSought,
        String newName, Element curr, XSDocumentInfo schemaDoc) {
    int result = 0;
    for (Element child = DOMUtil.getFirstChildElement(curr);
    child != null; child = DOMUtil.getNextSiblingElement(child)) {
        String name = DOMUtil.getLocalName(child);
        if (!name.equals(elementSought))
            result += changeRedefineGroup(originalQName, elementSought, newName, child, schemaDoc);
        else {
            String ref = child.getAttribute( SchemaSymbols.ATT_REF );
            if (ref.length() != 0) {
                String processedRef = findQName(ref, schemaDoc);
                if (originalQName.equals(processedRef)) {
                    String prefix = XMLSymbols.EMPTY_STRING;
                    int colonptr = ref.indexOf(":");
                    if (colonptr > 0) {
                        prefix = ref.substring(0,colonptr);
                        child.setAttribute(SchemaSymbols.ATT_REF, prefix + ":" + newName);
                    }
                    else
                        child.setAttribute(SchemaSymbols.ATT_REF, newName);
                    result++;
                    if (elementSought.equals(SchemaSymbols.ELT_GROUP)) {
                        String minOccurs = child.getAttribute( SchemaSymbols.ATT_MINOCCURS );
                        String maxOccurs = child.getAttribute( SchemaSymbols.ATT_MAXOCCURS );
                        if (!((maxOccurs.length() == 0 || maxOccurs.equals("1"))
                                && (minOccurs.length() == 0 || minOccurs.equals("1")))) {
                            reportSchemaError("src-redefine.6.1.2", new Object [] {ref}, child);
                        }
                    }
                }
            } // if ref was null some other stage of processing will flag the error
        }
    }
    return result;
}
 
Example 6
Source File: XSDComplexTypeTraverser.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private boolean isAttrOrAttrGroup(Element e) {
    String elementName = DOMUtil.getLocalName(e);

    if (elementName.equals(SchemaSymbols.ELT_ATTRIBUTE) ||
            elementName.equals(SchemaSymbols.ELT_ATTRIBUTEGROUP) ||
            elementName.equals(SchemaSymbols.ELT_ANYATTRIBUTE))
        return true;
    else
        return false;
}
 
Example 7
Source File: XSDHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private int changeRedefineGroup(String originalQName, String elementSought,
        String newName, Element curr, XSDocumentInfo schemaDoc) {
    int result = 0;
    for (Element child = DOMUtil.getFirstChildElement(curr);
    child != null; child = DOMUtil.getNextSiblingElement(child)) {
        String name = DOMUtil.getLocalName(child);
        if (!name.equals(elementSought))
            result += changeRedefineGroup(originalQName, elementSought, newName, child, schemaDoc);
        else {
            String ref = child.getAttribute( SchemaSymbols.ATT_REF );
            if (ref.length() != 0) {
                String processedRef = findQName(ref, schemaDoc);
                if (originalQName.equals(processedRef)) {
                    String prefix = XMLSymbols.EMPTY_STRING;
                    int colonptr = ref.indexOf(":");
                    if (colonptr > 0) {
                        prefix = ref.substring(0,colonptr);
                        child.setAttribute(SchemaSymbols.ATT_REF, prefix + ":" + newName);
                    }
                    else
                        child.setAttribute(SchemaSymbols.ATT_REF, newName);
                    result++;
                    if (elementSought.equals(SchemaSymbols.ELT_GROUP)) {
                        String minOccurs = child.getAttribute( SchemaSymbols.ATT_MINOCCURS );
                        String maxOccurs = child.getAttribute( SchemaSymbols.ATT_MAXOCCURS );
                        if (!((maxOccurs.length() == 0 || maxOccurs.equals("1"))
                                && (minOccurs.length() == 0 || minOccurs.equals("1")))) {
                            reportSchemaError("src-redefine.6.1.2", new Object [] {ref}, child);
                        }
                    }
                }
            } // if ref was null some other stage of processing will flag the error
        }
    }
    return result;
}
 
Example 8
Source File: XSDComplexTypeTraverser.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
private boolean isAttrOrAttrGroup(Element e) {
    String elementName = DOMUtil.getLocalName(e);

    if (elementName.equals(SchemaSymbols.ELT_ATTRIBUTE) ||
            elementName.equals(SchemaSymbols.ELT_ATTRIBUTEGROUP) ||
            elementName.equals(SchemaSymbols.ELT_ANYATTRIBUTE))
        return true;
    else
        return false;
}
 
Example 9
Source File: XSDHandler.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private int changeRedefineGroup(String originalQName, String elementSought,
        String newName, Element curr, XSDocumentInfo schemaDoc) {
    int result = 0;
    for (Element child = DOMUtil.getFirstChildElement(curr);
    child != null; child = DOMUtil.getNextSiblingElement(child)) {
        String name = DOMUtil.getLocalName(child);
        if (!name.equals(elementSought))
            result += changeRedefineGroup(originalQName, elementSought, newName, child, schemaDoc);
        else {
            String ref = child.getAttribute( SchemaSymbols.ATT_REF );
            if (ref.length() != 0) {
                String processedRef = findQName(ref, schemaDoc);
                if (originalQName.equals(processedRef)) {
                    String prefix = XMLSymbols.EMPTY_STRING;
                    int colonptr = ref.indexOf(":");
                    if (colonptr > 0) {
                        prefix = ref.substring(0,colonptr);
                        child.setAttribute(SchemaSymbols.ATT_REF, prefix + ":" + newName);
                    }
                    else
                        child.setAttribute(SchemaSymbols.ATT_REF, newName);
                    result++;
                    if (elementSought.equals(SchemaSymbols.ELT_GROUP)) {
                        String minOccurs = child.getAttribute( SchemaSymbols.ATT_MINOCCURS );
                        String maxOccurs = child.getAttribute( SchemaSymbols.ATT_MAXOCCURS );
                        if (!((maxOccurs.length() == 0 || maxOccurs.equals("1"))
                                && (minOccurs.length() == 0 || minOccurs.equals("1")))) {
                            reportSchemaError("src-redefine.6.1.2", new Object [] {ref}, child);
                        }
                    }
                }
            } // if ref was null some other stage of processing will flag the error
        }
    }
    return result;
}
 
Example 10
Source File: XSDComplexTypeTraverser.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private boolean isAttrOrAttrGroup(Element e) {
    String elementName = DOMUtil.getLocalName(e);

    if (elementName.equals(SchemaSymbols.ELT_ATTRIBUTE) ||
            elementName.equals(SchemaSymbols.ELT_ATTRIBUTEGROUP) ||
            elementName.equals(SchemaSymbols.ELT_ANYATTRIBUTE))
        return true;
    else
        return false;
}
 
Example 11
Source File: XSDComplexTypeTraverser.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private boolean isAttrOrAttrGroup(Element e) {
    String elementName = DOMUtil.getLocalName(e);

    if (elementName.equals(SchemaSymbols.ELT_ATTRIBUTE) ||
            elementName.equals(SchemaSymbols.ELT_ATTRIBUTEGROUP) ||
            elementName.equals(SchemaSymbols.ELT_ANYATTRIBUTE))
        return true;
    else
        return false;
}
 
Example 12
Source File: XSDComplexTypeTraverser.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private boolean isAttrOrAttrGroup(Element e) {
    String elementName = DOMUtil.getLocalName(e);

    if (elementName.equals(SchemaSymbols.ELT_ATTRIBUTE) ||
            elementName.equals(SchemaSymbols.ELT_ATTRIBUTEGROUP) ||
            elementName.equals(SchemaSymbols.ELT_ANYATTRIBUTE))
        return true;
    else
        return false;
}
 
Example 13
Source File: XSDHandler.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private int changeRedefineGroup(String originalQName, String elementSought,
        String newName, Element curr, XSDocumentInfo schemaDoc) {
    int result = 0;
    for (Element child = DOMUtil.getFirstChildElement(curr);
    child != null; child = DOMUtil.getNextSiblingElement(child)) {
        String name = DOMUtil.getLocalName(child);
        if (!name.equals(elementSought))
            result += changeRedefineGroup(originalQName, elementSought, newName, child, schemaDoc);
        else {
            String ref = child.getAttribute( SchemaSymbols.ATT_REF );
            if (ref.length() != 0) {
                String processedRef = findQName(ref, schemaDoc);
                if (originalQName.equals(processedRef)) {
                    String prefix = XMLSymbols.EMPTY_STRING;
                    int colonptr = ref.indexOf(":");
                    if (colonptr > 0) {
                        prefix = ref.substring(0,colonptr);
                        child.setAttribute(SchemaSymbols.ATT_REF, prefix + ":" + newName);
                    }
                    else
                        child.setAttribute(SchemaSymbols.ATT_REF, newName);
                    result++;
                    if (elementSought.equals(SchemaSymbols.ELT_GROUP)) {
                        String minOccurs = child.getAttribute( SchemaSymbols.ATT_MINOCCURS );
                        String maxOccurs = child.getAttribute( SchemaSymbols.ATT_MAXOCCURS );
                        if (!((maxOccurs.length() == 0 || maxOccurs.equals("1"))
                                && (minOccurs.length() == 0 || minOccurs.equals("1")))) {
                            reportSchemaError("src-redefine.6.1.2", new Object [] {ref}, child);
                        }
                    }
                }
            } // if ref was null some other stage of processing will flag the error
        }
    }
    return result;
}
 
Example 14
Source File: XSDHandler.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
private int changeRedefineGroup(String originalQName, String elementSought,
        String newName, Element curr, XSDocumentInfo schemaDoc) {
    int result = 0;
    for (Element child = DOMUtil.getFirstChildElement(curr);
    child != null; child = DOMUtil.getNextSiblingElement(child)) {
        String name = DOMUtil.getLocalName(child);
        if (!name.equals(elementSought))
            result += changeRedefineGroup(originalQName, elementSought, newName, child, schemaDoc);
        else {
            String ref = child.getAttribute( SchemaSymbols.ATT_REF );
            if (ref.length() != 0) {
                String processedRef = findQName(ref, schemaDoc);
                if (originalQName.equals(processedRef)) {
                    String prefix = XMLSymbols.EMPTY_STRING;
                    int colonptr = ref.indexOf(":");
                    if (colonptr > 0) {
                        prefix = ref.substring(0,colonptr);
                        child.setAttribute(SchemaSymbols.ATT_REF, prefix + ":" + newName);
                    }
                    else
                        child.setAttribute(SchemaSymbols.ATT_REF, newName);
                    result++;
                    if (elementSought.equals(SchemaSymbols.ELT_GROUP)) {
                        String minOccurs = child.getAttribute( SchemaSymbols.ATT_MINOCCURS );
                        String maxOccurs = child.getAttribute( SchemaSymbols.ATT_MAXOCCURS );
                        if (!((maxOccurs.length() == 0 || maxOccurs.equals("1"))
                                && (minOccurs.length() == 0 || minOccurs.equals("1")))) {
                            reportSchemaError("src-redefine.6.1.2", new Object [] {ref}, child);
                        }
                    }
                }
            } // if ref was null some other stage of processing will flag the error
        }
    }
    return result;
}
 
Example 15
Source File: XSDAbstractTraverser.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
XSAnnotationImpl traverseAnnotationDecl(Element annotationDecl, Object[] parentAttrs,
        boolean isGlobal, XSDocumentInfo schemaDoc) {
    // General Attribute Checking
    Object[] attrValues = fAttrChecker.checkAttributes(annotationDecl, isGlobal, schemaDoc);
    fAttrChecker.returnAttrArray(attrValues, schemaDoc);

    String contents = DOMUtil.getAnnotation(annotationDecl);
    Element child = DOMUtil.getFirstChildElement(annotationDecl);
    if (child != null) {
        do {
            String name = DOMUtil.getLocalName(child);

            // the only valid children of "annotation" are
            // "appinfo" and "documentation"
            if (!((name.equals(SchemaSymbols.ELT_APPINFO)) ||
                    (name.equals(SchemaSymbols.ELT_DOCUMENTATION)))) {
                reportSchemaError("src-annotation", new Object[]{name}, child);
            }
            else {
                // General Attribute Checking
                // There is no difference between global or local appinfo/documentation,
                // so we assume it's always global.
                attrValues = fAttrChecker.checkAttributes(child, true, schemaDoc);
                fAttrChecker.returnAttrArray(attrValues, schemaDoc);
            }

            child = DOMUtil.getNextSiblingElement(child);
        }
        while (child != null);
    }
    // if contents was null, must have been some kind of error;
    // nothing to contribute to PSVI
    if (contents == null) return null;

    // find the grammar; fSchemaHandler must be known!
    SchemaGrammar grammar = fSchemaHandler.getGrammar(schemaDoc.fTargetNamespace);
    // fish out local attributes passed from parent
    Vector annotationLocalAttrs = (Vector)parentAttrs[XSAttributeChecker.ATTIDX_NONSCHEMA];
    // optimize for case where there are no local attributes
    if(annotationLocalAttrs != null && !annotationLocalAttrs.isEmpty()) {
        StringBuffer localStrBuffer = new StringBuffer(64);
        localStrBuffer.append(" ");
        // Vector should contain rawname value pairs
        int i = 0;
        while (i < annotationLocalAttrs.size()) {
            String rawname = (String)annotationLocalAttrs.elementAt(i++);
            int colonIndex = rawname.indexOf(':');
            String prefix, localpart;
            if (colonIndex == -1) {
                prefix = "";
                localpart = rawname;
            }
            else {
                prefix = rawname.substring(0,colonIndex);
                localpart = rawname.substring(colonIndex+1);
            }
            String uri = schemaDoc.fNamespaceSupport.getURI(fSymbolTable.addSymbol(prefix));
            if (annotationDecl.getAttributeNS(uri, localpart).length() != 0) {
                i++; // skip the next value, too
                continue;
            }
            localStrBuffer.append(rawname)
            .append("=\"");
            String value = (String)annotationLocalAttrs.elementAt(i++);
            // search for pesky "s and <s within attr value:
            value = processAttValue(value);
            localStrBuffer.append(value)
            .append("\" ");
        }
        // and now splice it into place; immediately after the annotation token, for simplicity's sake
        StringBuffer contentBuffer = new StringBuffer(contents.length() + localStrBuffer.length());
        int annotationTokenEnd = contents.indexOf(SchemaSymbols.ELT_ANNOTATION);
        // annotation must occur somewhere or we're in big trouble...
        if(annotationTokenEnd == -1) return null;
        annotationTokenEnd += SchemaSymbols.ELT_ANNOTATION.length();
        contentBuffer.append(contents.substring(0,annotationTokenEnd));
        contentBuffer.append(localStrBuffer.toString());
        contentBuffer.append(contents.substring(annotationTokenEnd, contents.length()));
        final String annotation = contentBuffer.toString();
        if (fValidateAnnotations) {
            schemaDoc.addAnnotation(new XSAnnotationInfo(annotation, annotationDecl));
        }
        return new XSAnnotationImpl(annotation, grammar);
    } else {
        if (fValidateAnnotations) {
            schemaDoc.addAnnotation(new XSAnnotationInfo(contents, annotationDecl));
        }
        return new XSAnnotationImpl(contents, grammar);
    }

}
 
Example 16
Source File: XSDAbstractTraverser.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
XSAnnotationImpl traverseAnnotationDecl(Element annotationDecl, Object[] parentAttrs,
        boolean isGlobal, XSDocumentInfo schemaDoc) {
    // General Attribute Checking
    Object[] attrValues = fAttrChecker.checkAttributes(annotationDecl, isGlobal, schemaDoc);
    fAttrChecker.returnAttrArray(attrValues, schemaDoc);

    String contents = DOMUtil.getAnnotation(annotationDecl);
    Element child = DOMUtil.getFirstChildElement(annotationDecl);
    if (child != null) {
        do {
            String name = DOMUtil.getLocalName(child);

            // the only valid children of "annotation" are
            // "appinfo" and "documentation"
            if (!((name.equals(SchemaSymbols.ELT_APPINFO)) ||
                    (name.equals(SchemaSymbols.ELT_DOCUMENTATION)))) {
                reportSchemaError("src-annotation", new Object[]{name}, child);
            }
            else {
                // General Attribute Checking
                // There is no difference between global or local appinfo/documentation,
                // so we assume it's always global.
                attrValues = fAttrChecker.checkAttributes(child, true, schemaDoc);
                fAttrChecker.returnAttrArray(attrValues, schemaDoc);
            }

            child = DOMUtil.getNextSiblingElement(child);
        }
        while (child != null);
    }
    // if contents was null, must have been some kind of error;
    // nothing to contribute to PSVI
    if (contents == null) return null;

    // find the grammar; fSchemaHandler must be known!
    SchemaGrammar grammar = fSchemaHandler.getGrammar(schemaDoc.fTargetNamespace);
    // fish out local attributes passed from parent
    Vector annotationLocalAttrs = (Vector)parentAttrs[XSAttributeChecker.ATTIDX_NONSCHEMA];
    // optimize for case where there are no local attributes
    if(annotationLocalAttrs != null && !annotationLocalAttrs.isEmpty()) {
        StringBuffer localStrBuffer = new StringBuffer(64);
        localStrBuffer.append(" ");
        // Vector should contain rawname value pairs
        int i = 0;
        while (i < annotationLocalAttrs.size()) {
            String rawname = (String)annotationLocalAttrs.elementAt(i++);
            int colonIndex = rawname.indexOf(':');
            String prefix, localpart;
            if (colonIndex == -1) {
                prefix = "";
                localpart = rawname;
            }
            else {
                prefix = rawname.substring(0,colonIndex);
                localpart = rawname.substring(colonIndex+1);
            }
            String uri = schemaDoc.fNamespaceSupport.getURI(fSymbolTable.addSymbol(prefix));
            if (annotationDecl.getAttributeNS(uri, localpart).length() != 0) {
                i++; // skip the next value, too
                continue;
            }
            localStrBuffer.append(rawname)
            .append("=\"");
            String value = (String)annotationLocalAttrs.elementAt(i++);
            // search for pesky "s and <s within attr value:
            value = processAttValue(value);
            localStrBuffer.append(value)
            .append("\" ");
        }
        // and now splice it into place; immediately after the annotation token, for simplicity's sake
        StringBuffer contentBuffer = new StringBuffer(contents.length() + localStrBuffer.length());
        int annotationTokenEnd = contents.indexOf(SchemaSymbols.ELT_ANNOTATION);
        // annotation must occur somewhere or we're in big trouble...
        if(annotationTokenEnd == -1) return null;
        annotationTokenEnd += SchemaSymbols.ELT_ANNOTATION.length();
        contentBuffer.append(contents.substring(0,annotationTokenEnd));
        contentBuffer.append(localStrBuffer.toString());
        contentBuffer.append(contents.substring(annotationTokenEnd, contents.length()));
        final String annotation = contentBuffer.toString();
        if (fValidateAnnotations) {
            schemaDoc.addAnnotation(new XSAnnotationInfo(annotation, annotationDecl));
        }
        return new XSAnnotationImpl(annotation, grammar);
    } else {
        if (fValidateAnnotations) {
            schemaDoc.addAnnotation(new XSAnnotationInfo(contents, annotationDecl));
        }
        return new XSAnnotationImpl(contents, grammar);
    }

}
 
Example 17
Source File: XSDAbstractTraverser.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
XSAnnotationImpl traverseAnnotationDecl(Element annotationDecl, Object[] parentAttrs,
        boolean isGlobal, XSDocumentInfo schemaDoc) {
    // General Attribute Checking
    Object[] attrValues = fAttrChecker.checkAttributes(annotationDecl, isGlobal, schemaDoc);
    fAttrChecker.returnAttrArray(attrValues, schemaDoc);

    String contents = DOMUtil.getAnnotation(annotationDecl);
    Element child = DOMUtil.getFirstChildElement(annotationDecl);
    if (child != null) {
        do {
            String name = DOMUtil.getLocalName(child);

            // the only valid children of "annotation" are
            // "appinfo" and "documentation"
            if (!((name.equals(SchemaSymbols.ELT_APPINFO)) ||
                    (name.equals(SchemaSymbols.ELT_DOCUMENTATION)))) {
                reportSchemaError("src-annotation", new Object[]{name}, child);
            }
            else {
                // General Attribute Checking
                // There is no difference between global or local appinfo/documentation,
                // so we assume it's always global.
                attrValues = fAttrChecker.checkAttributes(child, true, schemaDoc);
                fAttrChecker.returnAttrArray(attrValues, schemaDoc);
            }

            child = DOMUtil.getNextSiblingElement(child);
        }
        while (child != null);
    }
    // if contents was null, must have been some kind of error;
    // nothing to contribute to PSVI
    if (contents == null) return null;

    // find the grammar; fSchemaHandler must be known!
    SchemaGrammar grammar = fSchemaHandler.getGrammar(schemaDoc.fTargetNamespace);
    // fish out local attributes passed from parent
    Vector annotationLocalAttrs = (Vector)parentAttrs[XSAttributeChecker.ATTIDX_NONSCHEMA];
    // optimize for case where there are no local attributes
    if(annotationLocalAttrs != null && !annotationLocalAttrs.isEmpty()) {
        StringBuffer localStrBuffer = new StringBuffer(64);
        localStrBuffer.append(" ");
        // Vector should contain rawname value pairs
        int i = 0;
        while (i < annotationLocalAttrs.size()) {
            String rawname = (String)annotationLocalAttrs.elementAt(i++);
            int colonIndex = rawname.indexOf(':');
            String prefix, localpart;
            if (colonIndex == -1) {
                prefix = "";
                localpart = rawname;
            }
            else {
                prefix = rawname.substring(0,colonIndex);
                localpart = rawname.substring(colonIndex+1);
            }
            String uri = schemaDoc.fNamespaceSupport.getURI(fSymbolTable.addSymbol(prefix));
            if (annotationDecl.getAttributeNS(uri, localpart).length() != 0) {
                i++; // skip the next value, too
                continue;
            }
            localStrBuffer.append(rawname)
            .append("=\"");
            String value = (String)annotationLocalAttrs.elementAt(i++);
            // search for pesky "s and <s within attr value:
            value = processAttValue(value);
            localStrBuffer.append(value)
            .append("\" ");
        }
        // and now splice it into place; immediately after the annotation token, for simplicity's sake
        StringBuffer contentBuffer = new StringBuffer(contents.length() + localStrBuffer.length());
        int annotationTokenEnd = contents.indexOf(SchemaSymbols.ELT_ANNOTATION);
        // annotation must occur somewhere or we're in big trouble...
        if(annotationTokenEnd == -1) return null;
        annotationTokenEnd += SchemaSymbols.ELT_ANNOTATION.length();
        contentBuffer.append(contents.substring(0,annotationTokenEnd));
        contentBuffer.append(localStrBuffer.toString());
        contentBuffer.append(contents.substring(annotationTokenEnd, contents.length()));
        final String annotation = contentBuffer.toString();
        if (fValidateAnnotations) {
            schemaDoc.addAnnotation(new XSAnnotationInfo(annotation, annotationDecl));
        }
        return new XSAnnotationImpl(annotation, grammar);
    } else {
        if (fValidateAnnotations) {
            schemaDoc.addAnnotation(new XSAnnotationInfo(contents, annotationDecl));
        }
        return new XSAnnotationImpl(contents, grammar);
    }

}
 
Example 18
Source File: XSDAbstractTraverser.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
XSAnnotationImpl traverseAnnotationDecl(Element annotationDecl, Object[] parentAttrs,
        boolean isGlobal, XSDocumentInfo schemaDoc) {
    // General Attribute Checking
    Object[] attrValues = fAttrChecker.checkAttributes(annotationDecl, isGlobal, schemaDoc);
    fAttrChecker.returnAttrArray(attrValues, schemaDoc);

    String contents = DOMUtil.getAnnotation(annotationDecl);
    Element child = DOMUtil.getFirstChildElement(annotationDecl);
    if (child != null) {
        do {
            String name = DOMUtil.getLocalName(child);

            // the only valid children of "annotation" are
            // "appinfo" and "documentation"
            if (!((name.equals(SchemaSymbols.ELT_APPINFO)) ||
                    (name.equals(SchemaSymbols.ELT_DOCUMENTATION)))) {
                reportSchemaError("src-annotation", new Object[]{name}, child);
            }
            else {
                // General Attribute Checking
                // There is no difference between global or local appinfo/documentation,
                // so we assume it's always global.
                attrValues = fAttrChecker.checkAttributes(child, true, schemaDoc);
                fAttrChecker.returnAttrArray(attrValues, schemaDoc);
            }

            child = DOMUtil.getNextSiblingElement(child);
        }
        while (child != null);
    }
    // if contents was null, must have been some kind of error;
    // nothing to contribute to PSVI
    if (contents == null) return null;

    // find the grammar; fSchemaHandler must be known!
    SchemaGrammar grammar = fSchemaHandler.getGrammar(schemaDoc.fTargetNamespace);
    // fish out local attributes passed from parent
    Vector annotationLocalAttrs = (Vector)parentAttrs[XSAttributeChecker.ATTIDX_NONSCHEMA];
    // optimize for case where there are no local attributes
    if(annotationLocalAttrs != null && !annotationLocalAttrs.isEmpty()) {
        StringBuffer localStrBuffer = new StringBuffer(64);
        localStrBuffer.append(" ");
        // Vector should contain rawname value pairs
        int i = 0;
        while (i < annotationLocalAttrs.size()) {
            String rawname = (String)annotationLocalAttrs.elementAt(i++);
            int colonIndex = rawname.indexOf(':');
            String prefix, localpart;
            if (colonIndex == -1) {
                prefix = "";
                localpart = rawname;
            }
            else {
                prefix = rawname.substring(0,colonIndex);
                localpart = rawname.substring(colonIndex+1);
            }
            String uri = schemaDoc.fNamespaceSupport.getURI(fSymbolTable.addSymbol(prefix));
            if (annotationDecl.getAttributeNS(uri, localpart).length() != 0) {
                i++; // skip the next value, too
                continue;
            }
            localStrBuffer.append(rawname)
            .append("=\"");
            String value = (String)annotationLocalAttrs.elementAt(i++);
            // search for pesky "s and <s within attr value:
            value = processAttValue(value);
            localStrBuffer.append(value)
            .append("\" ");
        }
        // and now splice it into place; immediately after the annotation token, for simplicity's sake
        StringBuffer contentBuffer = new StringBuffer(contents.length() + localStrBuffer.length());
        int annotationTokenEnd = contents.indexOf(SchemaSymbols.ELT_ANNOTATION);
        // annotation must occur somewhere or we're in big trouble...
        if(annotationTokenEnd == -1) return null;
        annotationTokenEnd += SchemaSymbols.ELT_ANNOTATION.length();
        contentBuffer.append(contents.substring(0,annotationTokenEnd));
        contentBuffer.append(localStrBuffer.toString());
        contentBuffer.append(contents.substring(annotationTokenEnd, contents.length()));
        final String annotation = contentBuffer.toString();
        if (fValidateAnnotations) {
            schemaDoc.addAnnotation(new XSAnnotationInfo(annotation, annotationDecl));
        }
        return new XSAnnotationImpl(annotation, grammar);
    } else {
        if (fValidateAnnotations) {
            schemaDoc.addAnnotation(new XSAnnotationInfo(contents, annotationDecl));
        }
        return new XSAnnotationImpl(contents, grammar);
    }

}
 
Example 19
Source File: XSDAbstractTraverser.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
XSAnnotationImpl traverseAnnotationDecl(Element annotationDecl, Object[] parentAttrs,
        boolean isGlobal, XSDocumentInfo schemaDoc) {
    // General Attribute Checking
    Object[] attrValues = fAttrChecker.checkAttributes(annotationDecl, isGlobal, schemaDoc);
    fAttrChecker.returnAttrArray(attrValues, schemaDoc);

    String contents = DOMUtil.getAnnotation(annotationDecl);
    Element child = DOMUtil.getFirstChildElement(annotationDecl);
    if (child != null) {
        do {
            String name = DOMUtil.getLocalName(child);

            // the only valid children of "annotation" are
            // "appinfo" and "documentation"
            if (!((name.equals(SchemaSymbols.ELT_APPINFO)) ||
                    (name.equals(SchemaSymbols.ELT_DOCUMENTATION)))) {
                reportSchemaError("src-annotation", new Object[]{name}, child);
            }
            else {
                // General Attribute Checking
                // There is no difference between global or local appinfo/documentation,
                // so we assume it's always global.
                attrValues = fAttrChecker.checkAttributes(child, true, schemaDoc);
                fAttrChecker.returnAttrArray(attrValues, schemaDoc);
            }

            child = DOMUtil.getNextSiblingElement(child);
        }
        while (child != null);
    }
    // if contents was null, must have been some kind of error;
    // nothing to contribute to PSVI
    if (contents == null) return null;

    // find the grammar; fSchemaHandler must be known!
    SchemaGrammar grammar = fSchemaHandler.getGrammar(schemaDoc.fTargetNamespace);
    // fish out local attributes passed from parent
    Vector annotationLocalAttrs = (Vector)parentAttrs[XSAttributeChecker.ATTIDX_NONSCHEMA];
    // optimize for case where there are no local attributes
    if(annotationLocalAttrs != null && !annotationLocalAttrs.isEmpty()) {
        StringBuffer localStrBuffer = new StringBuffer(64);
        localStrBuffer.append(" ");
        // Vector should contain rawname value pairs
        int i = 0;
        while (i < annotationLocalAttrs.size()) {
            String rawname = (String)annotationLocalAttrs.elementAt(i++);
            int colonIndex = rawname.indexOf(':');
            String prefix, localpart;
            if (colonIndex == -1) {
                prefix = "";
                localpart = rawname;
            }
            else {
                prefix = rawname.substring(0,colonIndex);
                localpart = rawname.substring(colonIndex+1);
            }
            String uri = schemaDoc.fNamespaceSupport.getURI(fSymbolTable.addSymbol(prefix));
            if (annotationDecl.getAttributeNS(uri, localpart).length() != 0) {
                i++; // skip the next value, too
                continue;
            }
            localStrBuffer.append(rawname)
            .append("=\"");
            String value = (String)annotationLocalAttrs.elementAt(i++);
            // search for pesky "s and <s within attr value:
            value = processAttValue(value);
            localStrBuffer.append(value)
            .append("\" ");
        }
        // and now splice it into place; immediately after the annotation token, for simplicity's sake
        StringBuffer contentBuffer = new StringBuffer(contents.length() + localStrBuffer.length());
        int annotationTokenEnd = contents.indexOf(SchemaSymbols.ELT_ANNOTATION);
        // annotation must occur somewhere or we're in big trouble...
        if(annotationTokenEnd == -1) return null;
        annotationTokenEnd += SchemaSymbols.ELT_ANNOTATION.length();
        contentBuffer.append(contents.substring(0,annotationTokenEnd));
        contentBuffer.append(localStrBuffer.toString());
        contentBuffer.append(contents.substring(annotationTokenEnd, contents.length()));
        final String annotation = contentBuffer.toString();
        if (fValidateAnnotations) {
            schemaDoc.addAnnotation(new XSAnnotationInfo(annotation, annotationDecl));
        }
        return new XSAnnotationImpl(annotation, grammar);
    } else {
        if (fValidateAnnotations) {
            schemaDoc.addAnnotation(new XSAnnotationInfo(contents, annotationDecl));
        }
        return new XSAnnotationImpl(contents, grammar);
    }

}
 
Example 20
Source File: XSDAbstractTraverser.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
XSAnnotationImpl traverseAnnotationDecl(Element annotationDecl, Object[] parentAttrs,
        boolean isGlobal, XSDocumentInfo schemaDoc) {
    // General Attribute Checking
    Object[] attrValues = fAttrChecker.checkAttributes(annotationDecl, isGlobal, schemaDoc);
    fAttrChecker.returnAttrArray(attrValues, schemaDoc);

    String contents = DOMUtil.getAnnotation(annotationDecl);
    Element child = DOMUtil.getFirstChildElement(annotationDecl);
    if (child != null) {
        do {
            String name = DOMUtil.getLocalName(child);

            // the only valid children of "annotation" are
            // "appinfo" and "documentation"
            if (!((name.equals(SchemaSymbols.ELT_APPINFO)) ||
                    (name.equals(SchemaSymbols.ELT_DOCUMENTATION)))) {
                reportSchemaError("src-annotation", new Object[]{name}, child);
            }
            else {
                // General Attribute Checking
                // There is no difference between global or local appinfo/documentation,
                // so we assume it's always global.
                attrValues = fAttrChecker.checkAttributes(child, true, schemaDoc);
                fAttrChecker.returnAttrArray(attrValues, schemaDoc);
            }

            child = DOMUtil.getNextSiblingElement(child);
        }
        while (child != null);
    }
    // if contents was null, must have been some kind of error;
    // nothing to contribute to PSVI
    if (contents == null) return null;

    // find the grammar; fSchemaHandler must be known!
    SchemaGrammar grammar = fSchemaHandler.getGrammar(schemaDoc.fTargetNamespace);
    // fish out local attributes passed from parent
    @SuppressWarnings("unchecked")
    List<String> annotationLocalAttrs = (ArrayList<String>)parentAttrs[XSAttributeChecker.ATTIDX_NONSCHEMA];
    // optimize for case where there are no local attributes
    if(annotationLocalAttrs != null && !annotationLocalAttrs.isEmpty()) {
        StringBuilder localStrBuffer = new StringBuilder(64);
        localStrBuffer.append(" ");
        //ArrayList<>should contain rawname value pairs
        int i = 0;
        while (i < annotationLocalAttrs.size()) {
            String rawname = annotationLocalAttrs.get(i++);
            int colonIndex = rawname.indexOf(':');
            String prefix, localpart;
            if (colonIndex == -1) {
                prefix = "";
                localpart = rawname;
            }
            else {
                prefix = rawname.substring(0,colonIndex);
                localpart = rawname.substring(colonIndex+1);
            }
            String uri = schemaDoc.fNamespaceSupport.getURI(fSymbolTable.addSymbol(prefix));
            if (annotationDecl.getAttributeNS(uri, localpart).length() != 0) {
                i++; // skip the next value, too
                continue;
            }
            localStrBuffer.append(rawname)
            .append("=\"");
            String value = annotationLocalAttrs.get(i++);
            // search for pesky "s and <s within attr value:
            value = processAttValue(value);
            localStrBuffer.append(value)
            .append("\" ");
        }
        // and now splice it into place; immediately after the annotation token, for simplicity's sake
        StringBuilder contentBuffer = new StringBuilder(contents.length() + localStrBuffer.length());
        int annotationTokenEnd = contents.indexOf(SchemaSymbols.ELT_ANNOTATION);
        // annotation must occur somewhere or we're in big trouble...
        if(annotationTokenEnd == -1) return null;
        annotationTokenEnd += SchemaSymbols.ELT_ANNOTATION.length();
        contentBuffer.append(contents.substring(0,annotationTokenEnd));
        contentBuffer.append(localStrBuffer.toString());
        contentBuffer.append(contents.substring(annotationTokenEnd, contents.length()));
        final String annotation = contentBuffer.toString();
        if (fValidateAnnotations) {
            schemaDoc.addAnnotation(new XSAnnotationInfo(annotation, annotationDecl));
        }
        return new XSAnnotationImpl(annotation, grammar);
    } else {
        if (fValidateAnnotations) {
            schemaDoc.addAnnotation(new XSAnnotationInfo(contents, annotationDecl));
        }
        return new XSAnnotationImpl(contents, grammar);
    }

}