public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { // DOMForest only parses documents that are rearchable 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; } });
/** * Checks the correctness of the XML Schema documents and return true * if it's OK. * * <p> * This method performs a weaker version of the tests where error messages * are provided without line number information. So whenever possible * use {@link SchemaConstraintChecker}. * * @see SchemaConstraintChecker */ public boolean checkSchemaCorrectness(ErrorReceiver errorHandler) { try { SchemaFactory sf = SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI); ErrorReceiverFilter filter = new ErrorReceiverFilter(errorHandler); sf.setErrorHandler(filter); Set<String> roots = getRootDocuments(); Source[] sources = new Source[roots.size()]; int i=0; for (String root : roots) { sources[i++] = new DOMSource(get(root),root); } sf.newSchema(sources); return !filter.hadError(); } catch (SAXException e) { // the errors should have been reported return false; } }
/** * 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; }
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; } });
/** * 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; }
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; } });
/** * 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; }
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { // DOMForest only parses documents that are rearchable 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; } });
/** * 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; }
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; } });
/** * 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; }
public void parse( InputSource source, ContentHandler contentHandler, ErrorHandler errorHandler, EntityResolver entityResolver ) throws SAXException, IOException { String systemId = source.getSystemId(); Document dom = forest.get(systemId); if(dom==null) { // if no DOM tree is built for it, // let the fall back parser parse the original document. // // for example, XSOM parses datatypes.xsd (XML Schema part 2) // but this will never be built into the forest. fallbackParser.parse( source, contentHandler, errorHandler, entityResolver ); return; } scanner.scan( dom, contentHandler ); } }
public void parse( InputSource source, ContentHandler contentHandler, ErrorHandler errorHandler, EntityResolver entityResolver ) throws SAXException, IOException { String systemId = source.getSystemId(); Document dom = forest.get(systemId); if(dom==null) { // if no DOM tree is built for it, // let the fall back parser parse the original document. // // for example, XSOM parses datatypes.xsd (XML Schema part 2) // but this will never be built into the forest. fallbackParser.parse( source, contentHandler, errorHandler, entityResolver ); return; } scanner.scan( dom, contentHandler ); } }
public void parse( InputSource source, ContentHandler contentHandler, ErrorHandler errorHandler, EntityResolver entityResolver ) throws SAXException, IOException { String systemId = source.getSystemId(); Document dom = forest.get(systemId); if(dom==null) { // if no DOM tree is built for it, // let the fall back parser parse the original document. // // for example, XSOM parses datatypes.xsd (XML Schema part 2) // but this will never be built into the forest. fallbackParser.parse( source, contentHandler, errorHandler, entityResolver ); return; } scanner.scan( dom, contentHandler ); } }
public void parse( InputSource source, ContentHandler contentHandler, ErrorHandler errorHandler, EntityResolver entityResolver ) throws SAXException, IOException { String systemId = source.getSystemId(); Document dom = forest.get(systemId); if(dom==null) { // if no DOM tree is built for it, // let the fall back parser parse the original document. // // for example, XSOM parses datatypes.xsd (XML Schema part 2) // but this will never be built into the forest. fallbackParser.parse( source, contentHandler, errorHandler, entityResolver ); return; } scanner.scan( dom, contentHandler ); } }
public void parse( InputSource source, ContentHandler contentHandler, ErrorHandler errorHandler, EntityResolver entityResolver ) throws SAXException, IOException { String systemId = source.getSystemId(); Document dom = forest.get(systemId); if(dom==null) { // if no DOM tree is built for it, // let the fall back parser parse the original document. // // for example, XSOM parses datatypes.xsd (XML Schema part 2) // but this will never be built into the forest. fallbackParser.parse( source, contentHandler, errorHandler, entityResolver ); return; } scanner.scan( dom, contentHandler ); } }
/** * Parses a set of schemas inside a WSDL file. * * A WSDL file may contain multiple {@code <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(); }
/** * Parses a set of schemas inside a WSDL file. * * A WSDL file may contain multiple {@code <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(); }
/** * Parses a set of schemas inside a WSDL file. * * A WSDL file may contain multiple <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() ); NodeList schemas = wsdlDom.getElementsByTagNameNS(WellKnownNamespace.XML_SCHEMA,"schema"); for( int i=0; i<schemas.getLength(); i++ ) scanner.scan( (Element)schemas.item(i), xsomParser.getParserHandler() ); } return xsomParser.getResult(); }
/** * Parses a set of schemas inside a WSDL file. * * A WSDL file may contain multiple <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() ); NodeList schemas = wsdlDom.getElementsByTagNameNS(WellKnownNamespace.XML_SCHEMA,"schema"); for( int i=0; i<schemas.getLength(); i++ ) scanner.scan( (Element)schemas.item(i), xsomParser.getParserHandler() ); } return xsomParser.getResult(); }