com.sun.org.apache.xerces.internal.impl.xs.XSDDescription Java Examples

The following examples show how to use com.sun.org.apache.xerces.internal.impl.xs.XSDDescription. 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 openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private boolean isExistingGrammar(XSDDescription desc, boolean ignoreConflict) {
    SchemaGrammar sg = fGrammarBucket.getGrammar(desc.getTargetNamespace());
    if (sg == null) {
        return findGrammar(desc, ignoreConflict) != null;
    }
    else if (sg.isImmutable()) {
        return true;
    }
    else {
        try {
            return sg.getDocumentLocations().contains(XMLEntityManager.expandSystemId(desc.getLiteralSystemId(), desc.getBaseSystemId(), false));
        }
        catch (MalformedURIException e) {
            return false;
        }
    }
}
 
Example #2
Source File: XSDHandler.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private XMLInputSource resolveSchemaSource(XSDDescription desc, boolean mustResolve,
        Element referElement, boolean usePairs) {

    XMLInputSource schemaSource = null;
    try {
        Map<String, XMLSchemaLoader.LocationArray> pairs = usePairs ? fLocationPairs : Collections.emptyMap();
        schemaSource = XMLSchemaLoader.resolveDocument(desc, pairs, fEntityManager);
    }
    catch (IOException ex) {
        if (mustResolve) {
            reportSchemaError("schema_reference.4",
                    new Object[]{desc.getLocationHints()[0]},
                    referElement);
        }
        else {
            reportSchemaWarning("schema_reference.4",
                    new Object[]{desc.getLocationHints()[0]},
                    referElement);
        }
    }

    return schemaSource;
}
 
Example #3
Source File: XSDHandler.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private Element resolveSchema(XMLInputSource schemaSource, XSDDescription desc,
        boolean mustResolve, Element referElement) {

    if (schemaSource instanceof DOMInputSource) {
        return getSchemaDocument(desc.getTargetNamespace(), (DOMInputSource) schemaSource, mustResolve, desc.getContextType(), referElement);
    } // DOMInputSource
    else if (schemaSource instanceof SAXInputSource) {
        return getSchemaDocument(desc.getTargetNamespace(), (SAXInputSource) schemaSource, mustResolve, desc.getContextType(), referElement);
    } // SAXInputSource
    else if (schemaSource instanceof StAXInputSource) {
        return getSchemaDocument(desc.getTargetNamespace(), (StAXInputSource) schemaSource, mustResolve, desc.getContextType(), referElement);
    } // StAXInputSource
    else if (schemaSource instanceof XSInputSource) {
        return getSchemaDocument((XSInputSource) schemaSource, desc);
    } // XSInputSource
    return getSchemaDocument(desc.getTargetNamespace(), schemaSource, mustResolve, desc.getContextType(), referElement);
}
 
Example #4
Source File: XSDHandler.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private boolean isExistingGrammar(XSDDescription desc, boolean ignoreConflict) {
    SchemaGrammar sg = fGrammarBucket.getGrammar(desc.getTargetNamespace());
    if (sg == null) {
        return findGrammar(desc, ignoreConflict) != null;
    }
    else if (sg.isImmutable()) {
        return true;
    }
    else {
        try {
            return sg.getDocumentLocations().contains(XMLEntityManager.expandSystemId(desc.getLiteralSystemId(), desc.getBaseSystemId(), false));
        }
        catch (MalformedURIException e) {
            return false;
        }
    }
}
 
Example #5
Source File: XSDHandler.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
private boolean existingGrammars(Vector grammars) {
    int length = grammars.size();
    final XSDDescription desc = new XSDDescription();

    for (int i=0; i < length; i++) {
        final SchemaGrammar sg1 = (SchemaGrammar)grammars.elementAt(i);
        desc.setNamespace(sg1.getTargetNamespace());

        final SchemaGrammar sg2 = findGrammar(desc, false);
        if (sg2 != null) {
            return true;
        }
    }

    return false;
}
 
Example #6
Source File: XSDHandler.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private Element resolveSchema(XMLInputSource schemaSource, XSDDescription desc,
        boolean mustResolve, Element referElement) {

    if (schemaSource instanceof DOMInputSource) {
        return getSchemaDocument(desc.getTargetNamespace(), (DOMInputSource) schemaSource, mustResolve, desc.getContextType(), referElement);
    } // DOMInputSource
    else if (schemaSource instanceof SAXInputSource) {
        return getSchemaDocument(desc.getTargetNamespace(), (SAXInputSource) schemaSource, mustResolve, desc.getContextType(), referElement);
    } // SAXInputSource
    else if (schemaSource instanceof StAXInputSource) {
        return getSchemaDocument(desc.getTargetNamespace(), (StAXInputSource) schemaSource, mustResolve, desc.getContextType(), referElement);
    } // StAXInputSource
    else if (schemaSource instanceof XSInputSource) {
        return getSchemaDocument((XSInputSource) schemaSource, desc);
    } // XSInputSource
    return getSchemaDocument(desc.getTargetNamespace(), schemaSource, mustResolve, desc.getContextType(), referElement);
}
 
Example #7
Source File: XSDHandler.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
private boolean isExistingGrammar(XSDDescription desc, boolean ignoreConflict) {
    SchemaGrammar sg = fGrammarBucket.getGrammar(desc.getTargetNamespace());
    if (sg == null) {
        return findGrammar(desc, ignoreConflict) != null;
    }
    else if (sg.isImmutable()) {
        return true;
    }
    else {
        try {
            return sg.getDocumentLocations().contains(XMLEntityManager.expandSystemId(desc.getLiteralSystemId(), desc.getBaseSystemId(), false));
        }
        catch (MalformedURIException e) {
            return false;
        }
    }
}
 
Example #8
Source File: XSDHandler.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private boolean existingGrammars(Vector grammars) {
    int length = grammars.size();
    final XSDDescription desc = new XSDDescription();

    for (int i=0; i < length; i++) {
        final SchemaGrammar sg1 = (SchemaGrammar)grammars.elementAt(i);
        desc.setNamespace(sg1.getTargetNamespace());

        final SchemaGrammar sg2 = findGrammar(desc, false);
        if (sg2 != null) {
            return true;
        }
    }

    return false;
}
 
Example #9
Source File: XSDHandler.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private boolean existingGrammars(Vector grammars) {
    int length = grammars.size();
    final XSDDescription desc = new XSDDescription();

    for (int i=0; i < length; i++) {
        final SchemaGrammar sg1 = (SchemaGrammar)grammars.elementAt(i);
        desc.setNamespace(sg1.getTargetNamespace());

        final SchemaGrammar sg2 = findGrammar(desc, false);
        if (sg2 != null) {
            return true;
        }
    }

    return false;
}
 
Example #10
Source File: XSDHandler.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private Element resolveSchema(XMLInputSource schemaSource, XSDDescription desc,
        boolean mustResolve, Element referElement) {

    if (schemaSource instanceof DOMInputSource) {
        return getSchemaDocument(desc.getTargetNamespace(), (DOMInputSource) schemaSource, mustResolve, desc.getContextType(), referElement);
    } // DOMInputSource
    else if (schemaSource instanceof SAXInputSource) {
        return getSchemaDocument(desc.getTargetNamespace(), (SAXInputSource) schemaSource, mustResolve, desc.getContextType(), referElement);
    } // SAXInputSource
    else if (schemaSource instanceof StAXInputSource) {
        return getSchemaDocument(desc.getTargetNamespace(), (StAXInputSource) schemaSource, mustResolve, desc.getContextType(), referElement);
    } // StAXInputSource
    else if (schemaSource instanceof XSInputSource) {
        return getSchemaDocument((XSInputSource) schemaSource, desc);
    } // XSInputSource
    return getSchemaDocument(desc.getTargetNamespace(), schemaSource, mustResolve, desc.getContextType(), referElement);
}
 
Example #11
Source File: XSDHandler.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private boolean existingGrammars(Vector grammars) {
    int length = grammars.size();
    final XSDDescription desc = new XSDDescription();

    for (int i=0; i < length; i++) {
        final SchemaGrammar sg1 = (SchemaGrammar)grammars.elementAt(i);
        desc.setNamespace(sg1.getTargetNamespace());

        final SchemaGrammar sg2 = findGrammar(desc, false);
        if (sg2 != null) {
            return true;
        }
    }

    return false;
}
 
Example #12
Source File: XSDHandler.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private boolean existingGrammars(Vector grammars) {
    int length = grammars.size();
    final XSDDescription desc = new XSDDescription();

    for (int i=0; i < length; i++) {
        final SchemaGrammar sg1 = (SchemaGrammar)grammars.elementAt(i);
        desc.setNamespace(sg1.getTargetNamespace());

        final SchemaGrammar sg2 = findGrammar(desc, false);
        if (sg2 != null) {
            return true;
        }
    }

    return false;
}
 
Example #13
Source File: XSDHandler.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
private boolean existingGrammars(Vector grammars) {
    int length = grammars.size();
    final XSDDescription desc = new XSDDescription();

    for (int i=0; i < length; i++) {
        final SchemaGrammar sg1 = (SchemaGrammar)grammars.elementAt(i);
        desc.setNamespace(sg1.getTargetNamespace());

        final SchemaGrammar sg2 = findGrammar(desc, false);
        if (sg2 != null) {
            return true;
        }
    }

    return false;
}
 
Example #14
Source File: XSDHandler.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
private boolean isExistingGrammar(XSDDescription desc, boolean ignoreConflict) {
    SchemaGrammar sg = fGrammarBucket.getGrammar(desc.getTargetNamespace());
    if (sg == null) {
        return findGrammar(desc, ignoreConflict) != null;
    }
    else if (sg.isImmutable()) {
        return true;
    }
    else {
        try {
            return sg.getDocumentLocations().contains(XMLEntityManager.expandSystemId(desc.getLiteralSystemId(), desc.getBaseSystemId(), false));
        }
        catch (MalformedURIException e) {
            return false;
        }
    }
}
 
Example #15
Source File: XSDHandler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private boolean existingGrammars(Vector grammars) {
    int length = grammars.size();
    final XSDDescription desc = new XSDDescription();

    for (int i=0; i < length; i++) {
        final SchemaGrammar sg1 = (SchemaGrammar)grammars.elementAt(i);
        desc.setNamespace(sg1.getTargetNamespace());

        final SchemaGrammar sg2 = findGrammar(desc, false);
        if (sg2 != null) {
            return true;
        }
    }

    return false;
}
 
Example #16
Source File: XSDHandler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private XMLInputSource resolveSchemaSource(XSDDescription desc, boolean mustResolve,
        Element referElement, boolean usePairs) {

    XMLInputSource schemaSource = null;
    try {
        Map<String, XMLSchemaLoader.LocationArray> pairs = usePairs ? fLocationPairs : Collections.emptyMap();
        schemaSource = XMLSchemaLoader.resolveDocument(desc, pairs, fEntityManager);
    }
    catch (IOException ex) {
        if (mustResolve) {
            reportSchemaError("schema_reference.4",
                    new Object[]{desc.getLocationHints()[0]},
                    referElement);
        }
        else {
            reportSchemaWarning("schema_reference.4",
                    new Object[]{desc.getLocationHints()[0]},
                    referElement);
        }
    }

    return schemaSource;
}
 
Example #17
Source File: XSDHandler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private Element resolveSchema(XMLInputSource schemaSource, XSDDescription desc,
        boolean mustResolve, Element referElement) {

    if (schemaSource instanceof DOMInputSource) {
        return getSchemaDocument(desc.getTargetNamespace(), (DOMInputSource) schemaSource, mustResolve, desc.getContextType(), referElement);
    } // DOMInputSource
    else if (schemaSource instanceof SAXInputSource) {
        return getSchemaDocument(desc.getTargetNamespace(), (SAXInputSource) schemaSource, mustResolve, desc.getContextType(), referElement);
    } // SAXInputSource
    else if (schemaSource instanceof StAXInputSource) {
        return getSchemaDocument(desc.getTargetNamespace(), (StAXInputSource) schemaSource, mustResolve, desc.getContextType(), referElement);
    } // StAXInputSource
    else if (schemaSource instanceof XSInputSource) {
        return getSchemaDocument((XSInputSource) schemaSource, desc);
    } // XSInputSource
    return getSchemaDocument(desc.getTargetNamespace(), schemaSource, mustResolve, desc.getContextType(), referElement);
}
 
Example #18
Source File: XSDHandler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private boolean isExistingGrammar(XSDDescription desc, boolean ignoreConflict) {
    SchemaGrammar sg = fGrammarBucket.getGrammar(desc.getTargetNamespace());
    if (sg == null) {
        return findGrammar(desc, ignoreConflict) != null;
    }
    else if (sg.isImmutable()) {
        return true;
    }
    else {
        try {
            return sg.getDocumentLocations().contains(XMLEntityManager.expandSystemId(desc.getLiteralSystemId(), desc.getBaseSystemId(), false));
        }
        catch (MalformedURIException e) {
            return false;
        }
    }
}
 
Example #19
Source File: XSDHandler.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private XMLInputSource resolveSchemaSource(XSDDescription desc, boolean mustResolve,
        Element referElement, boolean usePairs) {

    XMLInputSource schemaSource = null;
    try {
        Map pairs = usePairs ? fLocationPairs : EMPTY_TABLE;
        schemaSource = XMLSchemaLoader.resolveDocument(desc, pairs, fEntityResolver);
    }
    catch (IOException ex) {
        if (mustResolve) {
            reportSchemaError("schema_reference.4",
                    new Object[]{desc.getLocationHints()[0]},
                    referElement);
        }
        else {
            reportSchemaWarning("schema_reference.4",
                    new Object[]{desc.getLocationHints()[0]},
                    referElement);
        }
    }

    return schemaSource;
}
 
Example #20
Source File: XSDHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private XMLInputSource resolveSchemaSource(XSDDescription desc, boolean mustResolve,
        Element referElement, boolean usePairs) {

    XMLInputSource schemaSource = null;
    try {
        Map<String, XMLSchemaLoader.LocationArray> pairs = usePairs ? fLocationPairs : Collections.emptyMap();
        schemaSource = XMLSchemaLoader.resolveDocument(desc, pairs, fEntityManager);
    }
    catch (IOException ex) {
        if (mustResolve) {
            reportSchemaError("schema_reference.4",
                    new Object[]{desc.getLocationHints()[0]},
                    referElement);
        }
        else {
            reportSchemaWarning("schema_reference.4",
                    new Object[]{desc.getLocationHints()[0]},
                    referElement);
        }
    }

    return schemaSource;
}
 
Example #21
Source File: XSDHandler.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private Element resolveSchema(XMLInputSource schemaSource, XSDDescription desc,
        boolean mustResolve, Element referElement) {

    if (schemaSource instanceof DOMInputSource) {
        return getSchemaDocument(desc.getTargetNamespace(), (DOMInputSource) schemaSource, mustResolve, desc.getContextType(), referElement);
    } // DOMInputSource
    else if (schemaSource instanceof SAXInputSource) {
        return getSchemaDocument(desc.getTargetNamespace(), (SAXInputSource) schemaSource, mustResolve, desc.getContextType(), referElement);
    } // SAXInputSource
    else if (schemaSource instanceof StAXInputSource) {
        return getSchemaDocument(desc.getTargetNamespace(), (StAXInputSource) schemaSource, mustResolve, desc.getContextType(), referElement);
    } // StAXInputSource
    else if (schemaSource instanceof XSInputSource) {
        return getSchemaDocument((XSInputSource) schemaSource, desc);
    } // XSInputSource
    return getSchemaDocument(desc.getTargetNamespace(), schemaSource, mustResolve, desc.getContextType(), referElement);
}
 
Example #22
Source File: XSDHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private boolean isExistingGrammar(XSDDescription desc, boolean ignoreConflict) {
    SchemaGrammar sg = fGrammarBucket.getGrammar(desc.getTargetNamespace());
    if (sg == null) {
        return findGrammar(desc, ignoreConflict) != null;
    }
    else if (sg.isImmutable()) {
        return true;
    }
    else {
        try {
            return sg.getDocumentLocations().contains(XMLEntityManager.expandSystemId(desc.getLiteralSystemId(), desc.getBaseSystemId(), false));
        }
        catch (MalformedURIException e) {
            return false;
        }
    }
}
 
Example #23
Source File: XSDHandler.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private boolean isExistingGrammar(XSDDescription desc, boolean ignoreConflict) {
    SchemaGrammar sg = fGrammarBucket.getGrammar(desc.getTargetNamespace());
    if (sg == null) {
        return findGrammar(desc, ignoreConflict) != null;
    }
    else if (sg.isImmutable()) {
        return true;
    }
    else {
        try {
            return sg.getDocumentLocations().contains(XMLEntityManager.expandSystemId(desc.getLiteralSystemId(), desc.getBaseSystemId(), false));
        }
        catch (MalformedURIException e) {
            return false;
        }
    }
}
 
Example #24
Source File: XSDHandler.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
private XMLInputSource resolveSchemaSource(XSDDescription desc, boolean mustResolve,
        Element referElement, boolean usePairs) {

    XMLInputSource schemaSource = null;
    try {
        Map<String, XMLSchemaLoader.LocationArray> pairs = usePairs ? fLocationPairs : Collections.emptyMap();
        schemaSource = XMLSchemaLoader.resolveDocument(desc, pairs, fEntityManager);
    }
    catch (IOException ex) {
        if (mustResolve) {
            reportSchemaError("schema_reference.4",
                    new Object[]{desc.getLocationHints()[0]},
                    referElement);
        }
        else {
            reportSchemaWarning("schema_reference.4",
                    new Object[]{desc.getLocationHints()[0]},
                    referElement);
        }
    }

    return schemaSource;
}
 
Example #25
Source File: XSDHandler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * getSchemaDocument method uses XMLInputSource to parse a schema document.
 * @param schemaNamespace
 * @param schemaSource
 * @param mustResolve
 * @param referType
 * @param referElement
 * @return A schema Element.
 */
private Element getSchemaDocument(XSInputSource schemaSource, XSDDescription desc) {

    SchemaGrammar[] grammars = schemaSource.getGrammars();
    short referType = desc.getContextType();

    if (grammars != null && grammars.length > 0) {
        Vector expandedGrammars = expandGrammars(grammars);
        // check for existing grammars in our bucket
        // and if there exist any, and namespace growth is
        // not enabled - we do nothing
        if (fNamespaceGrowth || !existingGrammars(expandedGrammars)) {
            addGrammars(expandedGrammars);
            if (referType == XSDDescription.CONTEXT_PREPARSE) {
                desc.setTargetNamespace(grammars[0].getTargetNamespace());
            }
        }
    }
    else {
        XSObject[] components = schemaSource.getComponents();
        if (components != null && components.length > 0) {
            Map<String, Vector> importDependencies = new HashMap();
            Vector expandedComponents = expandComponents(components, importDependencies);
            if (fNamespaceGrowth || canAddComponents(expandedComponents)) {
                addGlobalComponents(expandedComponents, importDependencies);
                if (referType == XSDDescription.CONTEXT_PREPARSE) {
                    desc.setTargetNamespace(components[0].getNamespace());
                }
            }
        }
    }
    return null;
}
 
Example #26
Source File: XSDHandler.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private void addGrammars(Vector grammars) {
    int length = grammars.size();
    XSDDescription desc = new XSDDescription();

    for (int i=0; i < length; i++) {
        final SchemaGrammar sg1 = (SchemaGrammar)grammars.elementAt(i);
        desc.setNamespace(sg1.getTargetNamespace());

        final SchemaGrammar sg2 = findGrammar(desc, fNamespaceGrowth);
        if (sg1 != sg2) {
            addGrammarComponents(sg1, sg2);
        }
    }
}
 
Example #27
Source File: XSDHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public XSDHandler (XSGrammarBucket gBucket) {
    this();
    fGrammarBucket = gBucket;

    // Note: don't use SchemaConfiguration internally
    //       we will get stack overflaw because
    //       XMLSchemaValidator will be instantiating XSDHandler...
    fSchemaGrammarDescription = new XSDDescription();
}
 
Example #28
Source File: XSDHandler.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
private void addGlobalComponents(Vector components, Map<String, Vector> importDependencies) {
    final XSDDescription desc = new XSDDescription();
    final int size = components.size();

    for (int i=0; i<size; i++) {
        addGlobalComponent((XSObject) components.elementAt(i), desc);
    }
    updateImportDependencies(importDependencies);
}
 
Example #29
Source File: XSDHandler.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public XSDHandler (XSGrammarBucket gBucket) {
    this();
    fGrammarBucket = gBucket;

    // Note: don't use SchemaConfiguration internally
    //       we will get stack overflaw because
    //       XMLSchemaValidator will be instantiating XSDHandler...
    fSchemaGrammarDescription = new XSDDescription();
}
 
Example #30
Source File: XSDHandler.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
private void addGlobalComponents(Vector components, Map<String, Vector> importDependencies) {
    final XSDDescription desc = new XSDDescription();
    final int size = components.size();

    for (int i=0; i<size; i++) {
        addGlobalComponent((XSObject) components.elementAt(i), desc);
    }
    updateImportDependencies(importDependencies);
}