com.sun.xml.internal.xsom.parser.XSOMParser Java Examples

The following examples show how to use com.sun.xml.internal.xsom.parser.XSOMParser. 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: ModelLoader.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parses a {@link DOMForest} into a {@link XSSchemaSet}.
 *
 * @return
 *      null if the parsing failed.
 */
public XSSchemaSet createXSOM(DOMForest forest, SCDBasedBindingSet scdBasedBindingSet) throws SAXException {
    // set up other parameters to XSOMParser
    XSOMParser reader = createXSOMParser(forest);

    // re-parse the transformed schemas
    for (String systemId : forest.getRootDocuments()) {
        errorReceiver.pollAbort();
        Document dom = forest.get(systemId);
        if (!dom.getDocumentElement().getNamespaceURI().equals(Const.JAXB_NSURI)) {
            reader.parse(systemId);
        }
    }

    XSSchemaSet result = reader.getResult();

    if(result!=null)
        scdBasedBindingSet.apply(result,errorReceiver);

    return result;
}
 
Example #2
Source File: ParserContext.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public ParserContext( XSOMParser owner, XMLParser parser ) {
    this.owner = owner;
    this.parser = parser;

    try (InputStream is = ParserContext.class.getResourceAsStream("datatypes.xsd")) {
        InputSource source = new InputSource(is);
        source.setSystemId("datatypes.xsd");
        parse(source);

        SchemaImpl xs = (SchemaImpl)
                schemaSet.getSchema("http://www.w3.org/2001/XMLSchema");
        xs.addSimpleType(schemaSet.anySimpleType,true);
        xs.addComplexType(schemaSet.anyType,true);
    } catch( SAXException | IOException e ) {
        // this must be a bug of XSOM
        throw new InternalError(e.getMessage());
    }
}
 
Example #3
Source File: ModelLoader.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parses a {@link DOMForest} into a {@link XSSchemaSet}.
 *
 * @return
 *      null if the parsing failed.
 */
public XSSchemaSet createXSOM(DOMForest forest, SCDBasedBindingSet scdBasedBindingSet) throws SAXException {
    // set up other parameters to XSOMParser
    XSOMParser reader = createXSOMParser(forest);

    // re-parse the transformed schemas
    for (String systemId : forest.getRootDocuments()) {
        errorReceiver.pollAbort();
        Document dom = forest.get(systemId);
        if (!dom.getDocumentElement().getNamespaceURI().equals(Const.JAXB_NSURI)) {
            reader.parse(systemId);
        }
    }

    XSSchemaSet result = reader.getResult();

    if(result!=null)
        scdBasedBindingSet.apply(result,errorReceiver);

    return result;
}
 
Example #4
Source File: ModelLoader.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public XSOMParser createXSOMParser(final DOMForest forest) {
    XSOMParser p = createXSOMParser(forest.createParser());
    p.setEntityResolver(new EntityResolver() {
        public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
            // DOMForest only parses documents that are reachable through systemIds,
            // and it won't pick up references like <xs:import namespace="..." /> without
            // @schemaLocation. So we still need to use an entity resolver here to resolve
            // these references, yet we don't want to just run them blindly, since if we do that
            // DOMForestParser always get the translated system ID when catalog is used
            // (where DOMForest records trees with their original system IDs.)
            if(systemId!=null && forest.get(systemId)!=null)
                return new InputSource(systemId);
            if(opt.entityResolver!=null)
                return opt.entityResolver.resolveEntity(publicId,systemId);

            return null;
        }
    });
    return p;
}
 
Example #5
Source File: ModelLoader.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parses a {@link DOMForest} into a {@link XSSchemaSet}.
 *
 * @return
 *      null if the parsing failed.
 */
public XSSchemaSet createXSOM(DOMForest forest, SCDBasedBindingSet scdBasedBindingSet) throws SAXException {
    // set up other parameters to XSOMParser
    XSOMParser reader = createXSOMParser(forest);

    // re-parse the transformed schemas
    for (String systemId : forest.getRootDocuments()) {
        errorReceiver.pollAbort();
        Document dom = forest.get(systemId);
        if (!dom.getDocumentElement().getNamespaceURI().equals(Const.JAXB_NSURI)) {
            reader.parse(systemId);
        }
    }

    XSSchemaSet result = reader.getResult();

    if(result!=null)
        scdBasedBindingSet.apply(result,errorReceiver);

    return result;
}
 
Example #6
Source File: ParserContext.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public ParserContext( XSOMParser owner, XMLParser parser ) {
    this.owner = owner;
    this.parser = parser;

    try {
        parse(new InputSource(ParserContext.class.getResource("datatypes.xsd").toExternalForm()));

        SchemaImpl xs = (SchemaImpl)
            schemaSet.getSchema("http://www.w3.org/2001/XMLSchema");
        xs.addSimpleType(schemaSet.anySimpleType,true);
        xs.addComplexType(schemaSet.anyType,true);
    } catch( SAXException e ) {
        // this must be a bug of XSOM
        if(e.getException()!=null)
            e.getException().printStackTrace();
        else
            e.printStackTrace();
        throw new InternalError();
    }
}
 
Example #7
Source File: ParserContext.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public ParserContext( XSOMParser owner, XMLParser parser ) {
    this.owner = owner;
    this.parser = parser;

    try {
        parse(new InputSource(ParserContext.class.getResource("datatypes.xsd").toExternalForm()));

        SchemaImpl xs = (SchemaImpl)
            schemaSet.getSchema("http://www.w3.org/2001/XMLSchema");
        xs.addSimpleType(schemaSet.anySimpleType,true);
        xs.addComplexType(schemaSet.anyType,true);
    } catch( SAXException e ) {
        // this must be a bug of XSOM
        if(e.getException()!=null)
            e.getException().printStackTrace();
        else
            e.printStackTrace();
        throw new InternalError();
    }
}
 
Example #8
Source File: ModelLoader.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public XSOMParser createXSOMParser(final DOMForest forest) {
    XSOMParser p = createXSOMParser(forest.createParser());
    p.setEntityResolver(new EntityResolver() {
        public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
            // DOMForest only parses documents that are reachable through systemIds,
            // and it won't pick up references like <xs:import namespace="..." /> without
            // @schemaLocation. So we still need to use an entity resolver here to resolve
            // these references, yet we don't want to just run them blindly, since if we do that
            // DOMForestParser always get the translated system ID when catalog is used
            // (where DOMForest records trees with their original system IDs.)
            if(systemId!=null && forest.get(systemId)!=null)
                return new InputSource(systemId);
            if(opt.entityResolver!=null)
                return opt.entityResolver.resolveEntity(publicId,systemId);

            return null;
        }
    });
    return p;
}
 
Example #9
Source File: ModelLoader.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parses a {@link DOMForest} into a {@link XSSchemaSet}.
 *
 * @return
 *      null if the parsing failed.
 */
public XSSchemaSet createXSOM(DOMForest forest, SCDBasedBindingSet scdBasedBindingSet) throws SAXException {
    // set up other parameters to XSOMParser
    XSOMParser reader = createXSOMParser(forest);

    // re-parse the transformed schemas
    for (String systemId : forest.getRootDocuments()) {
        errorReceiver.pollAbort();
        Document dom = forest.get(systemId);
        if (!dom.getDocumentElement().getNamespaceURI().equals(Const.JAXB_NSURI)) {
            reader.parse(systemId);
        }
    }

    XSSchemaSet result = reader.getResult();

    if(result!=null)
        scdBasedBindingSet.apply(result,errorReceiver);

    return result;
}
 
Example #10
Source File: ModelLoader.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public XSOMParser createXSOMParser(final DOMForest forest) {
    XSOMParser p = createXSOMParser(forest.createParser());
    p.setEntityResolver(new EntityResolver() {
        public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
            // DOMForest only parses documents that are reachable through systemIds,
            // and it won't pick up references like <xs:import namespace="..." /> without
            // @schemaLocation. So we still need to use an entity resolver here to resolve
            // these references, yet we don't want to just run them blindly, since if we do that
            // DOMForestParser always get the translated system ID when catalog is used
            // (where DOMForest records trees with their original system IDs.)
            if(systemId!=null && forest.get(systemId)!=null)
                return new InputSource(systemId);
            if(opt.entityResolver!=null)
                return opt.entityResolver.resolveEntity(publicId,systemId);

            return null;
        }
    });
    return p;
}
 
Example #11
Source File: ModelLoader.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public XSOMParser createXSOMParser(final DOMForest forest) {
    XSOMParser p = createXSOMParser(forest.createParser());
    p.setEntityResolver(new EntityResolver() {
        public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
            // DOMForest only parses documents that are reachable through systemIds,
            // and it won't pick up references like <xs:import namespace="..." /> without
            // @schemaLocation. So we still need to use an entity resolver here to resolve
            // these references, yet we don't want to just run them blindly, since if we do that
            // DOMForestParser always get the translated system ID when catalog is used
            // (where DOMForest records trees with their original system IDs.)
            if(systemId!=null && forest.get(systemId)!=null)
                return new InputSource(systemId);
            if(opt.entityResolver!=null)
                return opt.entityResolver.resolveEntity(publicId,systemId);

            return null;
        }
    });
    return p;
}
 
Example #12
Source File: ParserContext.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public ParserContext( XSOMParser owner, XMLParser parser ) {
    this.owner = owner;
    this.parser = parser;

    try {
        parse(new InputSource(ParserContext.class.getResource("datatypes.xsd").toExternalForm()));

        SchemaImpl xs = (SchemaImpl)
            schemaSet.getSchema("http://www.w3.org/2001/XMLSchema");
        xs.addSimpleType(schemaSet.anySimpleType,true);
        xs.addComplexType(schemaSet.anyType,true);
    } catch( SAXException e ) {
        // this must be a bug of XSOM
        if(e.getException()!=null)
            e.getException().printStackTrace();
        else
            e.printStackTrace();
        throw new InternalError();
    }
}
 
Example #13
Source File: ModelLoader.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parses a {@link DOMForest} into a {@link XSSchemaSet}.
 *
 * @return
 *      null if the parsing failed.
 */
public XSSchemaSet createXSOM(DOMForest forest, SCDBasedBindingSet scdBasedBindingSet) throws SAXException {
    // set up other parameters to XSOMParser
    XSOMParser reader = createXSOMParser(forest);

    // re-parse the transformed schemas
    for (String systemId : forest.getRootDocuments()) {
        errorReceiver.pollAbort();
        Document dom = forest.get(systemId);
        if (!dom.getDocumentElement().getNamespaceURI().equals(Const.JAXB_NSURI)) {
            reader.parse(systemId);
        }
    }

    XSSchemaSet result = reader.getResult();

    if(result!=null)
        scdBasedBindingSet.apply(result,errorReceiver);

    return result;
}
 
Example #14
Source File: ParserContext.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public ParserContext( XSOMParser owner, XMLParser parser ) {
    this.owner = owner;
    this.parser = parser;

    try {
        parse(new InputSource(ParserContext.class.getResource("datatypes.xsd").toExternalForm()));

        SchemaImpl xs = (SchemaImpl)
            schemaSet.getSchema("http://www.w3.org/2001/XMLSchema");
        xs.addSimpleType(schemaSet.anySimpleType,true);
        xs.addComplexType(schemaSet.anyType,true);
    } catch( SAXException e ) {
        // this must be a bug of XSOM
        if(e.getException()!=null)
            e.getException().printStackTrace();
        else
            e.printStackTrace();
        throw new InternalError();
    }
}
 
Example #15
Source File: ModelLoader.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public XSOMParser createXSOMParser(final DOMForest forest) {
    XSOMParser p = createXSOMParser(forest.createParser());
    p.setEntityResolver(new EntityResolver() {
        public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
            // DOMForest only parses documents that are reachable through systemIds,
            // and it won't pick up references like <xs:import namespace="..." /> without
            // @schemaLocation. So we still need to use an entity resolver here to resolve
            // these references, yet we don't want to just run them blindly, since if we do that
            // DOMForestParser always get the translated system ID when catalog is used
            // (where DOMForest records trees with their original system IDs.)
            if(systemId!=null && forest.get(systemId)!=null)
                return new InputSource(systemId);
            if(opt.entityResolver!=null)
                return opt.entityResolver.resolveEntity(publicId,systemId);

            return null;
        }
    });
    return p;
}
 
Example #16
Source File: ModelLoader.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parses a {@link DOMForest} into a {@link XSSchemaSet}.
 *
 * @return
 *      null if the parsing failed.
 */
public XSSchemaSet createXSOM(DOMForest forest, SCDBasedBindingSet scdBasedBindingSet) throws SAXException {
    // set up other parameters to XSOMParser
    XSOMParser reader = createXSOMParser(forest);

    // re-parse the transformed schemas
    for (String systemId : forest.getRootDocuments()) {
        errorReceiver.pollAbort();
        Document dom = forest.get(systemId);
        if (!dom.getDocumentElement().getNamespaceURI().equals(Const.JAXB_NSURI)) {
            reader.parse(systemId);
        }
    }

    XSSchemaSet result = reader.getResult();

    if(result!=null)
        scdBasedBindingSet.apply(result,errorReceiver);

    return result;
}
 
Example #17
Source File: ParserContext.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public ParserContext( XSOMParser owner, XMLParser parser ) {
    this.owner = owner;
    this.parser = parser;

    try {
        parse(new InputSource(ParserContext.class.getResource("datatypes.xsd").toExternalForm()));

        SchemaImpl xs = (SchemaImpl)
            schemaSet.getSchema("http://www.w3.org/2001/XMLSchema");
        xs.addSimpleType(schemaSet.anySimpleType,true);
        xs.addComplexType(schemaSet.anyType,true);
    } catch( SAXException e ) {
        // this must be a bug of XSOM
        if(e.getException()!=null)
            e.getException().printStackTrace();
        else
            e.printStackTrace();
        throw new InternalError();
    }
}
 
Example #18
Source File: ModelLoader.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parses a {@link DOMForest} into a {@link XSSchemaSet}.
 *
 * @return
 *      null if the parsing failed.
 */
public XSSchemaSet createXSOM(DOMForest forest, SCDBasedBindingSet scdBasedBindingSet) throws SAXException {
    // set up other parameters to XSOMParser
    XSOMParser reader = createXSOMParser(forest);

    // re-parse the transformed schemas
    for (String systemId : forest.getRootDocuments()) {
        errorReceiver.pollAbort();
        Document dom = forest.get(systemId);
        if (!dom.getDocumentElement().getNamespaceURI().equals(Const.JAXB_NSURI)) {
            reader.parse(systemId);
        }
    }

    XSSchemaSet result = reader.getResult();

    if(result!=null)
        scdBasedBindingSet.apply(result,errorReceiver);

    return result;
}
 
Example #19
Source File: ModelLoader.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public XSOMParser createXSOMParser(final DOMForest forest) {
    XSOMParser p = createXSOMParser(forest.createParser());
    p.setEntityResolver(new EntityResolver() {
        public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
            // DOMForest only parses documents that are reachable through systemIds,
            // and it won't pick up references like <xs:import namespace="..." /> without
            // @schemaLocation. So we still need to use an entity resolver here to resolve
            // these references, yet we don't want to just run them blindly, since if we do that
            // DOMForestParser always get the translated system ID when catalog is used
            // (where DOMForest records trees with their original system IDs.)
            if(systemId!=null && forest.get(systemId)!=null)
                return new InputSource(systemId);
            if(opt.entityResolver!=null)
                return opt.entityResolver.resolveEntity(publicId,systemId);

            return null;
        }
    });
    return p;
}
 
Example #20
Source File: ModelLoader.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public XSOMParser createXSOMParser(final DOMForest forest) {
    XSOMParser p = createXSOMParser(forest.createParser());
    p.setEntityResolver(new EntityResolver() {
        public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
            // DOMForest only parses documents that are reachable through systemIds,
            // and it won't pick up references like <xs:import namespace="..." /> without
            // @schemaLocation. So we still need to use an entity resolver here to resolve
            // these references, yet we don't want to just run them blindly, since if we do that
            // DOMForestParser always get the translated system ID when catalog is used
            // (where DOMForest records trees with their original system IDs.)
            if(systemId!=null && forest.get(systemId)!=null)
                return new InputSource(systemId);
            if(opt.entityResolver!=null)
                return opt.entityResolver.resolveEntity(publicId,systemId);

            return null;
        }
    });
    return p;
}
 
Example #21
Source File: ModelLoader.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parses a {@link DOMForest} into a {@link XSSchemaSet}.
 *
 * @return
 *      null if the parsing failed.
 */
public XSSchemaSet createXSOM(DOMForest forest, SCDBasedBindingSet scdBasedBindingSet) throws SAXException {
    // set up other parameters to XSOMParser
    XSOMParser reader = createXSOMParser(forest);

    // re-parse the transformed schemas
    for (String systemId : forest.getRootDocuments()) {
        errorReceiver.pollAbort();
        Document dom = forest.get(systemId);
        if (!dom.getDocumentElement().getNamespaceURI().equals(Const.JAXB_NSURI)) {
            reader.parse(systemId);
        }
    }

    XSSchemaSet result = reader.getResult();

    if(result!=null)
        scdBasedBindingSet.apply(result,errorReceiver);

    return result;
}
 
Example #22
Source File: ParserContext.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public ParserContext( XSOMParser owner, XMLParser parser ) {
    this.owner = owner;
    this.parser = parser;

    try {
        parse(new InputSource(ParserContext.class.getResource("datatypes.xsd").toExternalForm()));

        SchemaImpl xs = (SchemaImpl)
            schemaSet.getSchema("http://www.w3.org/2001/XMLSchema");
        xs.addSimpleType(schemaSet.anySimpleType,true);
        xs.addComplexType(schemaSet.anyType,true);
    } catch( SAXException e ) {
        // this must be a bug of XSOM
        if(e.getException()!=null)
            e.getException().printStackTrace();
        else
            e.printStackTrace();
        throw new InternalError();
    }
}
 
Example #23
Source File: ParserContext.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public ParserContext( XSOMParser owner, XMLParser parser ) {
    this.owner = owner;
    this.parser = parser;

    try {
        parse(new InputSource(ParserContext.class.getResource("datatypes.xsd").toExternalForm()));

        SchemaImpl xs = (SchemaImpl)
            schemaSet.getSchema("http://www.w3.org/2001/XMLSchema");
        xs.addSimpleType(schemaSet.anySimpleType,true);
        xs.addComplexType(schemaSet.anyType,true);
    } catch( SAXException e ) {
        // this must be a bug of XSOM
        if(e.getException()!=null)
            e.getException().printStackTrace();
        else
            e.printStackTrace();
        throw new InternalError();
    }
}
 
Example #24
Source File: ModelLoader.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Potentially problematic - make sure the parser instance passed is initialized
 * with proper security feature.
 *
 * @param parser
 * @return
 */
public XSOMParser createXSOMParser(XMLParser parser) {
    // set up other parameters to XSOMParser
    XSOMParser reader = new XSOMParser(new XMLSchemaParser(parser));
    reader.setAnnotationParser(new AnnotationParserFactoryImpl(opt));
    reader.setErrorHandler(errorReceiver);
    reader.setEntityResolver(opt.entityResolver);
    return reader;
}
 
Example #25
Source File: ModelLoader.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Potentially problematic - make sure the parser instance passed is initialized
 * with proper security feature.
 *
 * @param parser
 * @return
 */
public XSOMParser createXSOMParser(XMLParser parser) {
    // set up other parameters to XSOMParser
    XSOMParser reader = new XSOMParser(new XMLSchemaParser(parser));
    reader.setAnnotationParser(new AnnotationParserFactoryImpl(opt));
    reader.setErrorHandler(errorReceiver);
    reader.setEntityResolver(opt.entityResolver);
    return reader;
}
 
Example #26
Source File: ModelLoader.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Parses a set of schemas inside a WSDL file.
 *
 * A WSDL file may contain multiple &lt;xsd:schema> elements.
 */
private XSSchemaSet loadWSDL()
    throws SAXException {


    // build DOMForest just like we handle XML Schema
    DOMForest forest = buildDOMForest( new XMLSchemaInternalizationLogic() );

    DOMForestScanner scanner = new DOMForestScanner(forest);

    XSOMParser xsomParser = createXSOMParser( forest );

    // find <xsd:schema>s and parse them individually
    for( InputSource grammar : opt.getGrammars() ) {
        Document wsdlDom = forest.get( grammar.getSystemId() );
        if (wsdlDom == null) {
            String systemId = Options.normalizeSystemId(grammar.getSystemId());
            if (forest.get(systemId) != null) {
                grammar.setSystemId(systemId);
                wsdlDom = forest.get( grammar.getSystemId() );
            }
        }

        NodeList schemas = wsdlDom.getElementsByTagNameNS(XMLConstants.W3C_XML_SCHEMA_NS_URI,"schema");
        for( int i=0; i<schemas.getLength(); i++ )
            scanner.scan( (Element)schemas.item(i), xsomParser.getParserHandler() );
    }
    return xsomParser.getResult();
}
 
Example #27
Source File: WhitespacesTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider = "TestSchemaFiles")
public void testWhitespacesCollapse(String schemaFile) throws Exception {
    XSOMParser parser = new XSOMParser(SAXParserFactory.newInstance());
    XsomErrorHandler eh = new XsomErrorHandler();

    parser.setErrorHandler(eh);
    parser.parse(getSchemaFile(schemaFile));

    if (eh.gotError) {
        throw new RuntimeException("XSOM parser encountered error", eh.e);
    }
}
 
Example #28
Source File: ModelLoader.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Parses a set of schemas inside a WSDL file.
 *
 * A WSDL file may contain multiple &lt;xsd:schema> elements.
 */
private XSSchemaSet loadWSDL()
    throws SAXException {


    // build DOMForest just like we handle XML Schema
    DOMForest forest = buildDOMForest( new XMLSchemaInternalizationLogic() );

    DOMForestScanner scanner = new DOMForestScanner(forest);

    XSOMParser xsomParser = createXSOMParser( forest );

    // find <xsd:schema>s and parse them individually
    for( InputSource grammar : opt.getGrammars() ) {
        Document wsdlDom = forest.get( grammar.getSystemId() );
        if (wsdlDom == null) {
            String systemId = Options.normalizeSystemId(grammar.getSystemId());
            if (forest.get(systemId) != null) {
                grammar.setSystemId(systemId);
                wsdlDom = forest.get( grammar.getSystemId() );
            }
        }

        NodeList schemas = wsdlDom.getElementsByTagNameNS(XMLConstants.W3C_XML_SCHEMA_NS_URI,"schema");
        for( int i=0; i<schemas.getLength(); i++ )
            scanner.scan( (Element)schemas.item(i), xsomParser.getParserHandler() );
    }
    return xsomParser.getResult();
}
 
Example #29
Source File: ModelLoader.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Potentially problematic - make sure the parser instance passed is initialized
 * with proper security feature.
 *
 * @param parser
 * @return
 */
public XSOMParser createXSOMParser(XMLParser parser) {
    // set up other parameters to XSOMParser
    XSOMParser reader = new XSOMParser(new XMLSchemaParser(parser));
    reader.setAnnotationParser(new AnnotationParserFactoryImpl(opt));
    reader.setErrorHandler(errorReceiver);
    reader.setEntityResolver(opt.entityResolver);
    return reader;
}
 
Example #30
Source File: WhitespacesTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider = "TestSchemaFiles")
public void testWhitespacesCollapse(String schemaFile) throws Exception {
    XSOMParser parser = new XSOMParser(SAXParserFactory.newInstance());
    XsomErrorHandler eh = new XsomErrorHandler();

    parser.setErrorHandler(eh);
    parser.parse(getSchemaFile(schemaFile));

    if (eh.gotError) {
        throw new RuntimeException("XSOM parser encountered error", eh.e);
    }
}