Here are the examples of the java api class com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource taken from open source projects.
1. EntityResolver2Wrapper#createXMLInputSource()
Project: openjdk
File: EntityResolver2Wrapper.java
File: EntityResolver2Wrapper.java
// resolveEntity(XMLResourceIdentifier):XMLInputSource /** * Creates an XMLInputSource from a SAX InputSource. */ private XMLInputSource createXMLInputSource(InputSource source, String baseURI) { String publicId = source.getPublicId(); String systemId = source.getSystemId(); String baseSystemId = baseURI; InputStream byteStream = source.getByteStream(); Reader charStream = source.getCharacterStream(); String encoding = source.getEncoding(); XMLInputSource xmlInputSource = new XMLInputSource(publicId, systemId, baseSystemId, false); xmlInputSource.setByteStream(byteStream); xmlInputSource.setCharacterStream(charStream); xmlInputSource.setEncoding(encoding); return xmlInputSource; }
2. PreParseGrammarTest#main()
Project: openjdk
File: PreParseGrammarTest.java
File: PreParseGrammarTest.java
public static void main(String[] args) throws FileNotFoundException, XNIException, IOException { File xsdf = new File(System.getProperty("test.src", ".") + "/test.xsd"); InputStream is = new BufferedInputStream(new FileInputStream(xsdf)); XMLInputSource xis = new XMLInputSource(null, null, null, is, null); XMLGrammarPreparser gp = new XMLGrammarPreparser(); gp.registerPreparser(XMLGrammarDescription.XML_SCHEMA, null); //The NullPointerException is observed on next call during ant task // execution Grammar res = gp.preparseGrammar(XMLGrammarDescription.XML_SCHEMA, xis); System.out.println("Grammar preparsed successfully:" + res); return; }
3. XSDHandler#resolveSchemaSource()
Project: openjdk
File: XSDHandler.java
File: XSDHandler.java
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; }
4. XSDHandler#validateAnnotations()
Project: openjdk
File: XSDHandler.java
File: XSDHandler.java
// end parseSchema private void validateAnnotations(ArrayList annotationInfo) { if (fAnnotationValidator == null) { createAnnotationValidator(); } final int size = annotationInfo.size(); final XMLInputSource src = new XMLInputSource(null, null, null, false); fGrammarBucketAdapter.refreshGrammars(fGrammarBucket); for (int i = 0; i < size; i += 2) { src.setSystemId((String) annotationInfo.get(i)); XSAnnotationInfo annotation = (XSAnnotationInfo) annotationInfo.get(i + 1); while (annotation != null) { src.setCharacterStream(new StringReader(annotation.fAnnotation)); try { fAnnotationValidator.parse(src); } catch (IOException exc) { } annotation = annotation.next; } } }
5. XMLInputFactoryImpl#createXMLStreamReader()
Project: openjdk
File: XMLInputFactoryImpl.java
File: XMLInputFactoryImpl.java
public XMLStreamReader createXMLStreamReader(InputStream inputstream, String encoding) throws XMLStreamException { XMLInputSource inputSource = new XMLInputSource(null, null, null, inputstream, encoding); return getXMLStreamReaderImpl(inputSource); }
6. XMLInputFactoryImpl#createXMLStreamReader()
Project: openjdk
File: XMLInputFactoryImpl.java
File: XMLInputFactoryImpl.java
public XMLStreamReader createXMLStreamReader(String systemId, InputStream inputstream) throws XMLStreamException { XMLInputSource inputSource = new XMLInputSource(null, systemId, null, inputstream, null); return getXMLStreamReaderImpl(inputSource); }
7. XMLInputFactoryImpl#createXMLStreamReader()
Project: openjdk
File: XMLInputFactoryImpl.java
File: XMLInputFactoryImpl.java
public XMLStreamReader createXMLStreamReader(String systemId, Reader reader) throws XMLStreamException { XMLInputSource inputSource = new XMLInputSource(null, systemId, null, reader, null); return getXMLStreamReaderImpl(inputSource); }
8. XMLInputFactoryImpl#createXMLStreamReader()
Project: openjdk
File: XMLInputFactoryImpl.java
File: XMLInputFactoryImpl.java
public XMLStreamReader createXMLStreamReader(Reader reader) throws XMLStreamException { XMLInputSource inputSource = new XMLInputSource(null, null, null, reader, null); return getXMLStreamReaderImpl(inputSource); }
9. XMLInputFactoryImpl#createXMLStreamReader()
Project: openjdk
File: XMLInputFactoryImpl.java
File: XMLInputFactoryImpl.java
public XMLStreamReader createXMLStreamReader(InputStream inputstream) throws XMLStreamException { XMLInputSource inputSource = new XMLInputSource(null, null, null, inputstream, null); return getXMLStreamReaderImpl(inputSource); }
10. XMLGrammarCachingConfiguration#parseGrammar()
Project: openjdk
File: XMLGrammarCachingConfiguration.java
File: XMLGrammarCachingConfiguration.java
// unlockGrammarPool() /** * Parse a grammar from a location identified by an URI. * This method also adds this grammar to the XMLGrammarPool * * @param type The type of the grammar to be constructed * @param uri The location of the grammar to be constructed. * <strong>The parser will not expand this URI or make it * available to the EntityResolver</strong> * @return The newly created <code>Grammar</code>. * @exception XNIException thrown on an error in grammar * construction * @exception IOException thrown if an error is encountered * in reading the file */ public Grammar parseGrammar(String type, String uri) throws XNIException, IOException { XMLInputSource source = new XMLInputSource(null, uri, null, false); return parseGrammar(type, source); }
11. DOMParserImpl#dom2xmlInputSource()
Project: openjdk
File: DOMParserImpl.java
File: DOMParserImpl.java
/** * NON-DOM: convert LSInput to XNIInputSource * * @param is * @return */ XMLInputSource dom2xmlInputSource(LSInput is) { // need to wrap the LSInput with an XMLInputSource XMLInputSource xis = null; // according to DOM, we need to treat such reader as "UTF-16". if (is.getCharacterStream() != null) { xis = new XMLInputSource(is.getPublicId(), is.getSystemId(), is.getBaseURI(), is.getCharacterStream(), "UTF-16"); } else // check whether there is an InputStream if (is.getByteStream() != null) { xis = new XMLInputSource(is.getPublicId(), is.getSystemId(), is.getBaseURI(), is.getByteStream(), is.getEncoding()); } else // according to DOM, we need to treat such data as "UTF-16". if (is.getStringData() != null && is.getStringData().length() > 0) { xis = new XMLInputSource(is.getPublicId(), is.getSystemId(), is.getBaseURI(), new StringReader(is.getStringData()), "UTF-16"); } else // otherwise, just use the public/system/base Ids if ((is.getSystemId() != null && is.getSystemId().length() > 0) || (is.getPublicId() != null && is.getPublicId().length() > 0)) { xis = new XMLInputSource(is.getPublicId(), is.getSystemId(), is.getBaseURI(), false); } else { // all inputs are null if (fErrorHandler != null) { DOMErrorImpl error = new DOMErrorImpl(); error.fType = "no-input-specified"; error.fMessage = "no-input-specified"; error.fSeverity = DOMError.SEVERITY_FATAL_ERROR; fErrorHandler.getErrorHandler().handleError(error); } throw new LSException(LSException.PARSE_ERR, "no-input-specified"); } return xis; }
12. DOMParserImpl#parse()
Project: openjdk
File: DOMParserImpl.java
File: DOMParserImpl.java
/** * Parse an XML document from a resource identified by an * <code>LSInput</code>. * */ public Document parse(LSInput is) throws LSException { // need to wrap the LSInput with an XMLInputSource XMLInputSource xmlInputSource = dom2xmlInputSource(is); if (fBusy) { String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_STATE_ERR", null); throw new DOMException(DOMException.INVALID_STATE_ERR, msg); } try { currentThread = Thread.currentThread(); fBusy = true; parse(xmlInputSource); fBusy = false; if (abortNow && currentThread.isInterrupted()) { //reset interrupt state abortNow = false; Thread.interrupted(); } } catch (Exception e) { fBusy = false; if (abortNow && currentThread.isInterrupted()) { Thread.interrupted(); } if (abortNow) { abortNow = false; restoreHandlers(); return null; } if (e != Abort.INSTANCE) { if (!(e instanceof XMLParseException) && fErrorHandler != null) { DOMErrorImpl error = new DOMErrorImpl(); error.fException = e; error.fMessage = e.getMessage(); error.fSeverity = DOMError.SEVERITY_FATAL_ERROR; fErrorHandler.getErrorHandler().handleError(error); } if (DEBUG) { e.printStackTrace(); } throw (LSException) DOMUtil.createLSException(LSException.PARSE_ERR, e).fillInStackTrace(); } } Document doc = getDocument(); dropDocumentReferences(); return doc; }
13. DOMParserImpl#parseURI()
Project: openjdk
File: DOMParserImpl.java
File: DOMParserImpl.java
/** * Parse an XML document from a location identified by an URI reference. * If the URI contains a fragment identifier (see section 4.1 in ), the * behavior is not defined by this specification. * */ public Document parseURI(String uri) throws LSException { // method is called, then raise INVALID_STATE_ERR according to DOM L3 LS spec if (fBusy) { String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_STATE_ERR", null); throw new DOMException(DOMException.INVALID_STATE_ERR, msg); } XMLInputSource source = new XMLInputSource(null, uri, null, false); try { currentThread = Thread.currentThread(); fBusy = true; parse(source); fBusy = false; if (abortNow && currentThread.isInterrupted()) { //reset interrupt state abortNow = false; Thread.interrupted(); } } catch (Exception e) { fBusy = false; if (abortNow && currentThread.isInterrupted()) { Thread.interrupted(); } if (abortNow) { abortNow = false; restoreHandlers(); return null; } if (e != Abort.INSTANCE) { if (!(e instanceof XMLParseException) && fErrorHandler != null) { DOMErrorImpl error = new DOMErrorImpl(); error.fException = e; error.fMessage = e.getMessage(); error.fSeverity = DOMError.SEVERITY_FATAL_ERROR; fErrorHandler.getErrorHandler().handleError(error); } if (DEBUG) { e.printStackTrace(); } throw (LSException) DOMUtil.createLSException(LSException.PARSE_ERR, e).fillInStackTrace(); } } Document doc = getDocument(); dropDocumentReferences(); return doc; }
14. DOMParser#parse()
Project: openjdk
File: DOMParser.java
File: DOMParser.java
// <init>(SymbolTable,XMLGrammarPool) // // XMLReader methods // /** * Parses the input source specified by the given system identifier. * <p> * This method is equivalent to the following: * <pre> * parse(new InputSource(systemId)); * </pre> * * @param systemId The system identifier (URI). * * @exception org.xml.sax.SAXException Throws exception on SAX error. * @exception java.io.IOException Throws exception on i/o error. */ public void parse(String systemId) throws SAXException, IOException { // parse document XMLInputSource source = new XMLInputSource(null, systemId, null, false); try { parse(source); }// wrap XNI exceptions as SAX exceptions catch (XMLParseException e) { Exception ex = e.getException(); if (ex == null) { LocatorImpl locatorImpl = new LocatorImpl(); locatorImpl.setPublicId(e.getPublicId()); locatorImpl.setSystemId(e.getExpandedSystemId()); locatorImpl.setLineNumber(e.getLineNumber()); locatorImpl.setColumnNumber(e.getColumnNumber()); throw new SAXParseException(e.getMessage(), locatorImpl); } if (ex instanceof SAXException) { throw (SAXException) ex; } if (ex instanceof IOException) { throw (IOException) ex; } throw new SAXException(ex); } catch (XNIException e) { e.printStackTrace(); Exception ex = e.getException(); if (ex == null) { throw new SAXException(e.getMessage()); } if (ex instanceof SAXException) { throw (SAXException) ex; } if (ex instanceof IOException) { throw (IOException) ex; } throw new SAXException(ex); } }
15. AbstractSAXParser#parse()
Project: openjdk
File: AbstractSAXParser.java
File: AbstractSAXParser.java
// endDTD() // // Parser and XMLReader methods // /** * Parses the input source specified by the given system identifier. * <p> * This method is equivalent to the following: * <pre> * parse(new InputSource(systemId)); * </pre> * * @param systemId The system identifier (URI). * * @exception org.xml.sax.SAXException Throws exception on SAX error. * @exception java.io.IOException Throws exception on i/o error. */ public void parse(String systemId) throws SAXException, IOException { // parse document XMLInputSource source = new XMLInputSource(null, systemId, null, false); try { parse(source); }// wrap XNI exceptions as SAX exceptions catch (XMLParseException e) { Exception ex = e.getException(); if (ex == null) { LocatorImpl locatorImpl = new LocatorImpl() { public String getXMLVersion() { return fVersion; } public String getEncoding() { return null; } }; locatorImpl.setPublicId(e.getPublicId()); locatorImpl.setSystemId(e.getExpandedSystemId()); locatorImpl.setLineNumber(e.getLineNumber()); locatorImpl.setColumnNumber(e.getColumnNumber()); throw new SAXParseException(e.getMessage(), locatorImpl); } if (ex instanceof SAXException) { throw (SAXException) ex; } if (ex instanceof IOException) { throw (IOException) ex; } throw new SAXException(ex); } catch (XNIException e) { Exception ex = e.getException(); if (ex == null) { throw new SAXException(e.getMessage()); } if (ex instanceof SAXException) { throw (SAXException) ex; } if (ex instanceof IOException) { throw (IOException) ex; } throw new SAXException(ex); } }
16. XMLSchemaFactory#newSchema()
Project: openjdk
File: XMLSchemaFactory.java
File: XMLSchemaFactory.java
public Schema newSchema(Source[] schemas) throws SAXException { // this will let the loader store parsed Grammars into the pool. XMLGrammarPoolImplExtension pool = new XMLGrammarPoolImplExtension(); fXMLGrammarPoolWrapper.setGrammarPool(pool); XMLInputSource[] xmlInputSources = new XMLInputSource[schemas.length]; InputStream inputStream; Reader reader; for (int i = 0; i < schemas.length; ++i) { Source source = schemas[i]; if (source instanceof StreamSource) { StreamSource streamSource = (StreamSource) source; String publicId = streamSource.getPublicId(); String systemId = streamSource.getSystemId(); inputStream = streamSource.getInputStream(); reader = streamSource.getReader(); XMLInputSource xmlInputSource = new XMLInputSource(publicId, systemId, null, false); xmlInputSource.setByteStream(inputStream); xmlInputSource.setCharacterStream(reader); xmlInputSources[i] = xmlInputSource; } else if (source instanceof SAXSource) { SAXSource saxSource = (SAXSource) source; InputSource inputSource = saxSource.getInputSource(); if (inputSource == null) { throw new SAXException(JAXPValidationMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(), "SAXSourceNullInputSource", null)); } xmlInputSources[i] = new SAXInputSource(saxSource.getXMLReader(), inputSource); } else if (source instanceof DOMSource) { DOMSource domSource = (DOMSource) source; Node node = domSource.getNode(); String systemID = domSource.getSystemId(); xmlInputSources[i] = new DOMInputSource(node, systemID); } else if (source instanceof StAXSource) { StAXSource staxSource = (StAXSource) source; XMLEventReader eventReader = staxSource.getXMLEventReader(); if (eventReader != null) { xmlInputSources[i] = new StAXInputSource(eventReader); } else { xmlInputSources[i] = new StAXInputSource(staxSource.getXMLStreamReader()); } } else if (source == null) { throw new NullPointerException(JAXPValidationMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(), "SchemaSourceArrayMemberNull", null)); } else { throw new IllegalArgumentException(JAXPValidationMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(), "SchemaFactorySourceUnrecognized", new Object[] { source.getClass().getName() })); } } try { fXMLSchemaLoader.loadGrammar(xmlInputSources); } catch (XNIException e) { throw Util.toSAXException(e); } catch (IOException e) { SAXParseException se = new SAXParseException(e.getMessage(), null, e); if (fErrorHandler != null) { fErrorHandler.error(se); } throw se; } // Clear reference to grammar pool. fXMLGrammarPoolWrapper.setGrammarPool(null); // Select Schema implementation based on grammar count. final int grammarCount = pool.getGrammarCount(); AbstractXMLSchema schema = null; if (fUseGrammarPoolOnly) { if (grammarCount > 1) { schema = new XMLSchema(new ReadOnlyGrammarPool(pool)); } else if (grammarCount == 1) { Grammar[] grammars = pool.retrieveInitialGrammarSet(XMLGrammarDescription.XML_SCHEMA); schema = new SimpleXMLSchema(grammars[0]); } else { schema = new EmptyXMLSchema(); } } else { schema = new XMLSchema(new ReadOnlyGrammarPool(pool), false); } propagateFeatures(schema); propagateProperties(schema); return schema; }
17. XMLSchemaLoader#dom2xmlInputSource()
Project: openjdk
File: XMLSchemaLoader.java
File: XMLSchemaLoader.java
XMLInputSource dom2xmlInputSource(LSInput is) { // need to wrap the LSInput with an XMLInputSource XMLInputSource xis = null; // according to DOM, we need to treat such reader as "UTF-16". if (is.getCharacterStream() != null) { xis = new XMLInputSource(is.getPublicId(), is.getSystemId(), is.getBaseURI(), is.getCharacterStream(), "UTF-16"); } else // check whether there is an InputStream if (is.getByteStream() != null) { xis = new XMLInputSource(is.getPublicId(), is.getSystemId(), is.getBaseURI(), is.getByteStream(), is.getEncoding()); } else // according to DOM, we need to treat such data as "UTF-16". if (is.getStringData() != null && is.getStringData().length() != 0) { xis = new XMLInputSource(is.getPublicId(), is.getSystemId(), is.getBaseURI(), new StringReader(is.getStringData()), "UTF-16"); } else // otherwise, just use the public/system/base Ids { xis = new XMLInputSource(is.getPublicId(), is.getSystemId(), is.getBaseURI(), false); } return xis; }
18. XMLSchemaLoader#processJAXPSchemaSource()
Project: openjdk
File: XMLSchemaLoader.java
File: XMLSchemaLoader.java
// tokenizeSchemaLocation(String, HashMap): boolean /** * Translate the various JAXP SchemaSource property types to XNI * XMLInputSource. Valid types are: String, org.xml.sax.InputSource, * InputStream, File, or Object[] of any of previous types. * REVISIT: the JAXP 1.2 spec is less than clear as to whether this property * should be available to imported schemas. I have assumed * that it should. - NG * Note: all JAXP schema files will be checked for full-schema validity if the feature was set up * */ private void processJAXPSchemaSource(Map<String, LocationArray> locationPairs) throws IOException { fJAXPProcessed = true; if (fJAXPSource == null) { return; } Class componentType = fJAXPSource.getClass().getComponentType(); XMLInputSource xis = null; String sid = null; if (componentType == null) { // Not an array if (fJAXPSource instanceof InputStream || fJAXPSource instanceof InputSource) { SchemaGrammar g = (SchemaGrammar) fJAXPCache.get(fJAXPSource); if (g != null) { fGrammarBucket.putGrammar(g); return; } } fXSDDescription.reset(); xis = xsdToXMLInputSource(fJAXPSource); sid = xis.getSystemId(); fXSDDescription.fContextType = XSDDescription.CONTEXT_PREPARSE; if (sid != null) { fXSDDescription.setBaseSystemId(xis.getBaseSystemId()); fXSDDescription.setLiteralSystemId(sid); fXSDDescription.setExpandedSystemId(sid); fXSDDescription.fLocationHints = new String[] { sid }; } SchemaGrammar g = loadSchema(fXSDDescription, xis, locationPairs); // it is possible that we won't be able to resolve JAXP schema-source location if (g != null) { if (fJAXPSource instanceof InputStream || fJAXPSource instanceof InputSource) { fJAXPCache.put(fJAXPSource, g); if (fIsCheckedFully) { XSConstraints.fullSchemaChecking(fGrammarBucket, fSubGroupHandler, fCMBuilder, fErrorReporter); } } fGrammarBucket.putGrammar(g); } return; } else if ((componentType != Object.class) && (componentType != String.class) && !File.class.isAssignableFrom(componentType) && !InputStream.class.isAssignableFrom(componentType) && !InputSource.class.isAssignableFrom(componentType) && !componentType.isInterface()) { // Not an Object[], String[], File[], InputStream[], InputSource[] MessageFormatter mf = fErrorReporter.getMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN); throw new XMLConfigurationException(Status.NOT_SUPPORTED, mf.formatMessage(fErrorReporter.getLocale(), "jaxp12-schema-source-type.2", new Object[] { componentType.getName() })); } // JAXP spec. allow []s of type String, File, InputStream, // InputSource also, apart from [] of type Object. Object[] objArr = (Object[]) fJAXPSource; // make local array for storing target namespaces of schemasources specified in object arrays. ArrayList jaxpSchemaSourceNamespaces = new ArrayList(); for (int i = 0; i < objArr.length; i++) { if (objArr[i] instanceof InputStream || objArr[i] instanceof InputSource) { SchemaGrammar g = (SchemaGrammar) fJAXPCache.get(objArr[i]); if (g != null) { fGrammarBucket.putGrammar(g); continue; } } fXSDDescription.reset(); xis = xsdToXMLInputSource(objArr[i]); sid = xis.getSystemId(); fXSDDescription.fContextType = XSDDescription.CONTEXT_PREPARSE; if (sid != null) { fXSDDescription.setBaseSystemId(xis.getBaseSystemId()); fXSDDescription.setLiteralSystemId(sid); fXSDDescription.setExpandedSystemId(sid); fXSDDescription.fLocationHints = new String[] { sid }; } String targetNamespace = null; // load schema SchemaGrammar grammar = fSchemaHandler.parseSchema(xis, fXSDDescription, locationPairs); if (fIsCheckedFully) { XSConstraints.fullSchemaChecking(fGrammarBucket, fSubGroupHandler, fCMBuilder, fErrorReporter); } if (grammar != null) { targetNamespace = grammar.getTargetNamespace(); if (jaxpSchemaSourceNamespaces.contains(targetNamespace)) { // when an array of objects is passed it is illegal to have two schemas that share same namespace. MessageFormatter mf = fErrorReporter.getMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN); throw new java.lang.IllegalArgumentException(mf.formatMessage(fErrorReporter.getLocale(), "jaxp12-schema-source-ns", null)); } else { jaxpSchemaSourceNamespaces.add(targetNamespace); } if (objArr[i] instanceof InputStream || objArr[i] instanceof InputSource) { fJAXPCache.put(objArr[i], grammar); } fGrammarBucket.putGrammar(grammar); } else { //REVISIT: What should be the acutal behavior if grammar can't be loaded as specified in schema source? } } }
19. XSDHandler#resolveSchema()
Project: openjdk
File: XSDHandler.java
File: XSDHandler.java
// storeKeyref (Element, XSDocumentInfo, XSElementDecl): void /** * resolveSchema method is responsible for resolving location of the schema (using XMLEntityResolver), * and if it was successfully resolved getting the schema Document. * @param desc * @param mustResolve * @param referElement * @return A schema Element or null. */ private Element resolveSchema(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); } } if (schemaSource instanceof DOMInputSource) { return getSchemaDocument(desc.getTargetNamespace(), (DOMInputSource) schemaSource, mustResolve, desc.getContextType(), referElement); } else // DOMInputSource if (schemaSource instanceof SAXInputSource) { return getSchemaDocument(desc.getTargetNamespace(), (SAXInputSource) schemaSource, mustResolve, desc.getContextType(), referElement); } else // SAXInputSource if (schemaSource instanceof StAXInputSource) { return getSchemaDocument(desc.getTargetNamespace(), (StAXInputSource) schemaSource, mustResolve, desc.getContextType(), referElement); } else // StAXInputSource if (schemaSource instanceof XSInputSource) { return getSchemaDocument((XSInputSource) schemaSource, desc); } // XSInputSource return getSchemaDocument(desc.getTargetNamespace(), schemaSource, mustResolve, desc.getContextType(), referElement); }
20. DOMNormalizer#createGrammarPool()
Project: openjdk
File: DOMNormalizer.java
File: DOMNormalizer.java
//normalizeNode private XMLGrammarPool createGrammarPool(DocumentTypeImpl docType) { XMLGrammarPoolImpl pool = new XMLGrammarPoolImpl(); XMLGrammarPreparser preParser = new XMLGrammarPreparser(fSymbolTable); preParser.registerPreparser(XMLGrammarDescription.XML_DTD, null); preParser.setFeature(Constants.XERCES_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE, true); preParser.setFeature(Constants.XERCES_FEATURE_PREFIX + Constants.VALIDATION_FEATURE, true); preParser.setProperty(Constants.XERCES_PROPERTY_PREFIX + Constants.XMLGRAMMAR_POOL_PROPERTY, pool); String internalSubset = docType.getInternalSubset(); XMLInputSource is = new XMLInputSource(docType.getPublicId(), docType.getSystemId(), null, false); if (internalSubset != null) is.setCharacterStream(new StringReader(internalSubset)); try { DTDGrammar g = (DTDGrammar) preParser.preparseGrammar(XMLGrammarDescription.XML_DTD, is); ((XMLDTDDescription) g.getGrammarDescription()).setRootName(docType.getName()); is.setCharacterStream(null); g = (DTDGrammar) preParser.preparseGrammar(XMLGrammarDescription.XML_DTD, is); ((XMLDTDDescription) g.getGrammarDescription()).setRootName(docType.getName()); } catch (XNIException e) { } catch (IOException e) { } return pool; }