Java Code Examples for org.xml.sax.InputSource#getSystemId()
The following examples show how to use
org.xml.sax.InputSource#getSystemId() .
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: DTDParser.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Parse a DTD. */ public void parse(String uri) throws IOException, SAXException { InputSource in; init(); // System.out.println ("parse (\"" + uri + "\")"); in = resolver.resolveEntity(null, uri); // If custom resolver punts resolution to parser, handle it ... if (in == null) { in = Resolver.createInputSource(new java.net.URL(uri), false); // ... or if custom resolver doesn't correctly construct the // input entity, patch it up enough so relative URIs work, and // issue a warning to minimize later confusion. } else if (in.getSystemId() == null) { warning("P-065", null); in.setSystemId(uri); } parseInternal(in); }
Example 2
Source File: EntityResolver2Wrapper.java From JDKSourceCode1.8 with MIT License | 6 votes |
/** * 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); xmlInputSource.setByteStream(byteStream); xmlInputSource.setCharacterStream(charStream); xmlInputSource.setEncoding(encoding); return xmlInputSource; }
Example 3
Source File: DOMForestParser.java From hottub with GNU General Public License v2.0 | 6 votes |
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 ); }
Example 4
Source File: DOMForestParser.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public void parse(InputSource source, ContentHandler handler, 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, handler, errorHandler, entityResolver); return; } scanner.scan(dom, handler); }
Example 5
Source File: DTDParser.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Parse a DTD. */ public void parse(String uri) throws IOException, SAXException { InputSource in; init(); // System.out.println ("parse (\"" + uri + "\")"); in = resolver.resolveEntity(null, uri); // If custom resolver punts resolution to parser, handle it ... if (in == null) { in = Resolver.createInputSource(new java.net.URL(uri), false); // ... or if custom resolver doesn't correctly construct the // input entity, patch it up enough so relative URIs work, and // issue a warning to minimize later confusion. } else if (in.getSystemId() == null) { warning("P-065", null); in.setSystemId(uri); } parseInternal(in); }
Example 6
Source File: DOMConfigurator.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
/** Configure log4j by reading in a log4j.dtd compliant XML configuration file. */ protected void doConfigure(final InputSource inputSource, LoggerRepository repository) throws FactoryConfigurationError { if (inputSource.getSystemId() == null) { inputSource.setSystemId("dummy://log4j.dtd"); } ParseAction action = new ParseAction() { public Document parse(final DocumentBuilder parser) throws SAXException, IOException { return parser.parse(inputSource); } public String toString() { return "input source [" + inputSource.toString() + "]"; } }; doConfigure(action, repository); }
Example 7
Source File: EntityResolver2Wrapper.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * 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); xmlInputSource.setByteStream(byteStream); xmlInputSource.setCharacterStream(charStream); xmlInputSource.setEncoding(encoding); return xmlInputSource; }
Example 8
Source File: SAXDocumentParser.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public void parse(InputSource input) throws IOException, SAXException { try { InputStream s = input.getByteStream(); if (s == null) { String systemId = input.getSystemId(); if (systemId == null) { throw new SAXException(CommonResourceBundle.getInstance().getString("message.inputSource")); } parse(systemId); } else { parse(s); } } catch (FastInfosetException e) { logger.log(Level.FINE, "parsing error", e); throw new SAXException(e); } }
Example 9
Source File: SAXDocumentParser.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public void parse(InputSource input) throws IOException, SAXException { try { InputStream s = input.getByteStream(); if (s == null) { String systemId = input.getSystemId(); if (systemId == null) { throw new SAXException(CommonResourceBundle.getInstance().getString("message.inputSource")); } parse(systemId); } else { parse(s); } } catch (FastInfosetException e) { logger.log(Level.FINE, "parsing error", e); throw new SAXException(e); } }
Example 10
Source File: XMLConfiguration.java From commons-configuration with Apache License 2.0 | 5 votes |
/** * Loads a configuration file from the specified input source. * * @param source the input source * @throws ConfigurationException if an error occurs */ private void load(final InputSource source) throws ConfigurationException { if (locator == null) { throw new ConfigurationException("Load operation not properly " + "initialized! Do not call read(InputStream) directly," + " but use a FileHandler to load a configuration."); } try { final URL sourceURL = locator.getSourceURL(); if (sourceURL != null) { source.setSystemId(sourceURL.toString()); } final DocumentBuilder builder = createDocumentBuilder(); final Document newDocument = builder.parse(source); final Document oldDocument = getDocument(); initProperties(XMLDocumentHelper.forSourceDocument(newDocument), oldDocument == null); } catch (final SAXParseException spe) { throw new ConfigurationException("Error parsing " + source.getSystemId(), spe); } catch (final Exception e) { this.getLogger().debug("Unable to load the configuration: " + e); throw new ConfigurationException("Unable to load the configuration", e); } }
Example 11
Source File: IncrementalSAXSource_Xerces.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private boolean parseSomeSetup(InputSource source) throws SAXException, IOException, IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.InstantiationException { if(fConfigSetInput!=null) { // Obtain input from SAX inputSource object, construct XNI version of // that object. Logic adapted from Xerces2. Object[] parms1={source.getPublicId(),source.getSystemId(),null}; Object xmlsource=fConfigInputSourceCtor.newInstance(parms1); Object[] parmsa={source.getByteStream()}; fConfigSetByteStream.invoke(xmlsource,parmsa); parmsa[0]=source.getCharacterStream(); fConfigSetCharStream.invoke(xmlsource,parmsa); parmsa[0]=source.getEncoding(); fConfigSetEncoding.invoke(xmlsource,parmsa); // Bugzilla5272 patch suggested by Sandy Gao. // Has to be reflection to run with Xerces2 // after compilation against Xerces1. or vice // versa, due to return type mismatches. Object[] noparms=new Object[0]; fReset.invoke(fIncrementalParser,noparms); parmsa[0]=xmlsource; fConfigSetInput.invoke(fPullParserConfig,parmsa); // %REVIEW% Do first pull. Should we instead just return true? return parseSome(); } else { Object[] parm={source}; Object ret=fParseSomeSetup.invoke(fIncrementalParser,parm); return ((Boolean)ret).booleanValue(); } }
Example 12
Source File: IncrementalSAXSource_Xerces.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private boolean parseSomeSetup(InputSource source) throws SAXException, IOException, IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.InstantiationException { if(fConfigSetInput!=null) { // Obtain input from SAX inputSource object, construct XNI version of // that object. Logic adapted from Xerces2. Object[] parms1={source.getPublicId(),source.getSystemId(),null}; Object xmlsource=fConfigInputSourceCtor.newInstance(parms1); Object[] parmsa={source.getByteStream()}; fConfigSetByteStream.invoke(xmlsource,parmsa); parmsa[0]=source.getCharacterStream(); fConfigSetCharStream.invoke(xmlsource,parmsa); parmsa[0]=source.getEncoding(); fConfigSetEncoding.invoke(xmlsource,parmsa); // Bugzilla5272 patch suggested by Sandy Gao. // Has to be reflection to run with Xerces2 // after compilation against Xerces1. or vice // versa, due to return type mismatches. Object[] noparms=new Object[0]; fReset.invoke(fIncrementalParser,noparms); parmsa[0]=xmlsource; fConfigSetInput.invoke(fPullParserConfig,parmsa); // %REVIEW% Do first pull. Should we instead just return true? return parseSome(); } else { Object[] parm={source}; Object ret=fParseSomeSetup.invoke(fIncrementalParser,parm); return ((Boolean)ret).booleanValue(); } }
Example 13
Source File: SAXInputSource.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public SAXInputSource(XMLReader reader, InputSource inputSource) { super(inputSource != null ? inputSource.getPublicId() : null, inputSource != null ? inputSource.getSystemId() : null, null); if (inputSource != null) { setByteStream(inputSource.getByteStream()); setCharacterStream(inputSource.getCharacterStream()); setEncoding(inputSource.getEncoding()); } fInputSource = inputSource; fXMLReader = reader; }
Example 14
Source File: XMLInputSource.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Constructs an input source from a SAX InputSource * object. * * @param inputSource a SAX InputSource * @param isCreatedByResolver a flag to indicate whether the source is * created by a resolver */ public XMLInputSource(InputSource inputSource, boolean isCreatedByResolver) { fPublicId = inputSource.getPublicId(); fSystemId = inputSource.getSystemId(); fByteStream = inputSource.getByteStream(); fCharStream = inputSource.getCharacterStream(); fEncoding = inputSource.getEncoding(); fIsCreatedByResolver = isCreatedByResolver; }
Example 15
Source File: AbstractWrapperWSDLLocator.java From cxf with Apache License 2.0 | 5 votes |
public InputSource getBaseInputSource() { InputSource is = parent.getBaseInputSource(); fromParent = true; if (is == null) { is = getInputSource(); fromParent = false; } else { baseUri = is.getSystemId(); } last = is; return is; }
Example 16
Source File: IncrementalSAXSource_Xerces.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private boolean parseSomeSetup(InputSource source) throws SAXException, IOException, IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.InstantiationException { if(fConfigSetInput!=null) { // Obtain input from SAX inputSource object, construct XNI version of // that object. Logic adapted from Xerces2. Object[] parms1={source.getPublicId(),source.getSystemId(),null}; Object xmlsource=fConfigInputSourceCtor.newInstance(parms1); Object[] parmsa={source.getByteStream()}; fConfigSetByteStream.invoke(xmlsource,parmsa); parmsa[0]=source.getCharacterStream(); fConfigSetCharStream.invoke(xmlsource,parmsa); parmsa[0]=source.getEncoding(); fConfigSetEncoding.invoke(xmlsource,parmsa); // Bugzilla5272 patch suggested by Sandy Gao. // Has to be reflection to run with Xerces2 // after compilation against Xerces1. or vice // versa, due to return type mismatches. Object[] noparms=new Object[0]; fReset.invoke(fIncrementalParser,noparms); parmsa[0]=xmlsource; fConfigSetInput.invoke(fPullParserConfig,parmsa); // %REVIEW% Do first pull. Should we instead just return true? return parseSome(); } else { Object[] parm={source}; Object ret=fParseSomeSetup.invoke(fIncrementalParser,parm); return ((Boolean)ret).booleanValue(); } }
Example 17
Source File: XmlUtils.java From CloverETL-Engine with GNU Lesser General Public License v2.1 | 5 votes |
public static void setSystemId(InputSource inputSource, URL contextUrl, String input) { if (inputSource.getSystemId() == null) { String systemId = XmlUtils.getSystemId(contextUrl, input); if (systemId != null) { inputSource.setSystemId(systemId); } } }
Example 18
Source File: SAXInputSource.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public SAXInputSource(XMLReader reader, InputSource inputSource) { super(inputSource != null ? inputSource.getPublicId() : null, inputSource != null ? inputSource.getSystemId() : null, null); if (inputSource != null) { setByteStream(inputSource.getByteStream()); setCharacterStream(inputSource.getCharacterStream()); setEncoding(inputSource.getEncoding()); } fInputSource = inputSource; fXMLReader = reader; }
Example 19
Source File: Util.java From netbeans with Apache License 2.0 | 5 votes |
public static FileObject toFileObject(InputSource src) { try { String sysId = src.getSystemId(); return FileUtil.toFileObject(new File(new URI(sysId))); } catch (URISyntaxException ex) { LOG.log(Level.WARNING, "File URI malformed", ex); return null; } }
Example 20
Source File: MCREntityResolver.java From mycore with GNU General Public License v3.0 | 4 votes |
private InputSource resolvedEntity(InputSource entity) { String msg = "Resolved to: " + entity.getSystemId() + "."; LOGGER.debug(msg); return entity; }