List of usage examples for org.xml.sax InputSource setSystemId
public void setSystemId(String systemId)
From source file:org.dita2indesign.indesign.builders.InDesignFromDitaMapBuilder.java
/** * @param transformContext//w w w .jav a 2 s . c o m * @param indesignTemplate * @param publicationMap * @return * @throws Exception * @throws IOException */ public InDesignDocument buildMapDocument(URL publicationMap, Map2InDesignOptions options) throws Exception { URL inDesignTemplate = options.getInDesignTemplate(); if (inDesignTemplate == null) { throw new Exception("InDesign template option not set."); } InputSource indesignTemplateSource = new InputSource(inDesignTemplate.openStream()); indesignTemplateSource.setSystemId(options.getInDesignTemplate().toExternalForm()); InputSource mapSource = new InputSource(publicationMap.openStream()); mapSource.setSystemId(publicationMap.toExternalForm()); return buildMapDocument(indesignTemplateSource, mapSource, options); }
From source file:org.docx4j.fonts.fop.fonts.LazyFont.java
private void load(boolean fail) { if (!isMetricsLoaded) { try {/*from ww w. j ava2s. c om*/ if (metricsFileName != null) { /**@todo Possible thread problem here */ FontReader reader = null; if (resolver != null) { Source source = resolver.resolve(metricsFileName); if (source == null) { String err = "Cannot load font: failed to create Source from metrics file " + metricsFileName; if (fail) { throw new RuntimeException(err); } else { log.error(err); } return; } InputStream in = null; if (source instanceof StreamSource) { in = ((StreamSource) source).getInputStream(); } if (in == null && source.getSystemId() != null) { in = new java.net.URL(source.getSystemId()).openStream(); } if (in == null) { String err = "Cannot load font: After URI resolution, the returned" + " Source object does not contain an InputStream" + " or a valid URL (system identifier) for metrics file: " + metricsFileName; if (fail) { throw new RuntimeException(err); } else { log.error(err); } return; } InputSource src = new InputSource(in); src.setSystemId(source.getSystemId()); reader = new FontReader(src); } else { reader = new FontReader(new InputSource(new URL(metricsFileName).openStream())); } reader.setKerningEnabled(useKerning); if (this.embedded) { reader.setFontEmbedPath(fontEmbedPath); } reader.setResolver(resolver); realFont = reader.getFont(); } else { if (fontEmbedPath == null) { throw new RuntimeException("Cannot load font. No font URIs available."); } realFont = FontLoader.loadFont(fontEmbedPath, this.subFontName, this.embedded, this.encodingMode, useKerning, resolver); } if (realFont instanceof FontDescriptor) { realFontDescriptor = (FontDescriptor) realFont; } } catch (FOPException fopex) { log.error("Failed to read font metrics file " + metricsFileName, fopex); if (fail) { throw new RuntimeException(fopex.getMessage()); } } catch (IOException ioex) { log.error("Failed to read font metrics file " + metricsFileName, ioex); if (fail) { throw new RuntimeException(ioex.getMessage()); } } realFont.setEventListener(this.eventListener); isMetricsLoaded = true; } }
From source file:org.echocat.adam.configuration.ConfigurationMarshaller.java
@Nullable public static Configuration unmarshall(@Nonnull Reader content, @Nullable String systemId) { try {//from w w w . jav a 2s. c o m final Unmarshaller unmarshaller = unmarshallerFor(content, systemId); final InputSource source = new InputSource(content); source.setSystemId(systemId != null ? systemId : "<unknownSource>"); return (Configuration) unmarshaller.unmarshal(source); } catch (final UnmarshalException e) { throw new ParseException(e, (systemId != null ? systemId : content.toString())); } catch (final JAXBException e) { throw new ConfigurationException("Could not unmarshall: " + (systemId != null ? systemId : content), e); } }
From source file:org.eclipse.rdf4j.rio.rdfxml.RDFXMLParser.java
/** * Parses the data from the supplied InputStream, using the supplied baseURI to resolve any relative URI * references./*from www.ja v a2s .com*/ * * @param in * The InputStream from which to read the data, must not be <tt>null</tt>. * @param baseURI * The URI associated with the data in the InputStream, must not be <tt>null</tt>. * @throws IOException * If an I/O error occurred while data was read from the InputStream. * @throws RDFParseException * If the parser has found an unrecoverable parse error. * @throws RDFHandlerException * If the configured statement handler encountered an unrecoverable error. * @throws IllegalArgumentException * If the supplied input stream or base URI is <tt>null</tt>. */ @Override public synchronized void parse(InputStream in, String baseURI) throws IOException, RDFParseException, RDFHandlerException { if (in == null) { throw new IllegalArgumentException("Input stream cannot be 'null'"); } if (baseURI == null) { throw new IllegalArgumentException("Base URI cannot be 'null'"); } InputSource inputSource = new InputSource(new BOMInputStream(in, false)); inputSource.setSystemId(baseURI); parse(inputSource); }
From source file:org.eclipse.rdf4j.rio.rdfxml.RDFXMLParser.java
/** * Parses the data from the supplied Reader, using the supplied baseURI to resolve any relative URI * references./*from w ww .ja va2 s.c o m*/ * * @param reader * The Reader from which to read the data, must not be <tt>null</tt>. * @param baseURI * The URI associated with the data in the InputStream, must not be <tt>null</tt>. * @throws IOException * If an I/O error occurred while data was read from the InputStream. * @throws RDFParseException * If the parser has found an unrecoverable parse error. * @throws RDFHandlerException * If the configured statement handler has encountered an unrecoverable error. * @throws IllegalArgumentException * If the supplied reader or base URI is <tt>null</tt>. */ @Override public synchronized void parse(Reader reader, String baseURI) throws IOException, RDFParseException, RDFHandlerException { if (reader == null) { throw new IllegalArgumentException("Reader cannot be 'null'"); } if (baseURI == null) { throw new IllegalArgumentException("Base URI cannot be 'null'"); } InputSource inputSource = new InputSource(reader); inputSource.setSystemId(baseURI); parse(inputSource); }
From source file:org.eclipse.rdf4j.rio.trix.TriXParser.java
/** * Parses the data from the supplied InputStream, using the supplied baseURI to resolve any relative URI * references.//from w ww. j a va 2 s .c o m * * @param in * The InputStream from which to read the data, must not be <tt>null</tt>. * @param baseURI * The URI associated with the data in the InputStream, must not be <tt>null</tt>. * @throws IOException * If an I/O error occurred while data was read from the InputStream. * @throws RDFParseException * If the parser has found an unrecoverable parse error. * @throws RDFHandlerException * If the configured statement handler encountered an unrecoverable error. * @throws IllegalArgumentException * If the supplied input stream or base URI is <tt>null</tt>. */ @Override public void parse(InputStream in, String baseURI) throws IOException, RDFParseException, RDFHandlerException { if (in == null) { throw new IllegalArgumentException("Input stream cannot be 'null'"); } if (baseURI == null) { throw new IllegalArgumentException("Base URI cannot be 'null'"); } InputSource inputSource = new InputSource(new BOMInputStream(in, false)); inputSource.setSystemId(baseURI); parse(inputSource); }
From source file:org.eclipse.rdf4j.rio.trix.TriXParser.java
/** * Parses the data from the supplied Reader, using the supplied baseURI to resolve any relative URI * references.//from www . j a v a 2 s .c o m * * @param reader * The Reader from which to read the data, must not be <tt>null</tt>. * @param baseURI * The URI associated with the data in the InputStream, must not be <tt>null</tt>. * @throws IOException * If an I/O error occurred while data was read from the InputStream. * @throws RDFParseException * If the parser has found an unrecoverable parse error. * @throws RDFHandlerException * If the configured statement handler has encountered an unrecoverable error. * @throws IllegalArgumentException * If the supplied reader or base URI is <tt>null</tt>. */ @Override public void parse(Reader reader, String baseURI) throws IOException, RDFParseException, RDFHandlerException { if (reader == null) { throw new IllegalArgumentException("Reader cannot be 'null'"); } if (baseURI == null) { throw new IllegalArgumentException("Base URI cannot be 'null'"); } InputSource inputSource = new InputSource(reader); inputSource.setSystemId(baseURI); parse(inputSource); }
From source file:org.exist.collections.Collection.java
private InputSource closeShieldInputSource(final InputSource source) { final InputSource protectedInputSource = new InputSource(); protectedInputSource.setEncoding(source.getEncoding()); protectedInputSource.setSystemId(source.getSystemId()); protectedInputSource.setPublicId(source.getPublicId()); if (source.getByteStream() != null) { //TODO consider AutoCloseInputStream final InputStream closeShieldByteStream = new CloseShieldInputStream(source.getByteStream()); protectedInputSource.setByteStream(closeShieldByteStream); }/* ww w .ja va 2 s . c o m*/ if (source.getCharacterStream() != null) { //TODO consider AutoCloseReader final Reader closeShieldReader = new CloseShieldReader(source.getCharacterStream()); protectedInputSource.setCharacterStream(closeShieldReader); } return protectedInputSource; }
From source file:org.exist.collections.MutableCollection.java
private InputSource closeShieldInputSource(final InputSource source) { final InputSource protectedInputSource = new InputSource(); protectedInputSource.setEncoding(source.getEncoding()); protectedInputSource.setSystemId(source.getSystemId()); protectedInputSource.setPublicId(source.getPublicId()); if (source.getByteStream() != null) { //TODO consider AutoCloseInputStream final InputStream closeShieldByteStream = new CloseShieldInputStream(source.getByteStream()); protectedInputSource.setByteStream(closeShieldByteStream); }// www . ja v a 2 s. c o m if (source.getCharacterStream() != null) { //TODO consider AutoCloseReader final Reader closeShieldReader = new CloseShieldReader(source.getCharacterStream()); protectedInputSource.setCharacterStream(closeShieldReader); } return protectedInputSource; }
From source file:org.exolab.castor.mapping.Mapping.java
/** * Loads the mapping from the specified URL. If an entity resolver was specified, will use the * entity resolver to resolve the URL. This method is also used to load mappings referenced from * another mapping or configuration file. * * @param url The URL of the mapping file. * @param type The source type./*from w w w . j a v a 2s . c o m*/ * @throws IOException An error occured when reading the mapping file. * @throws MappingException The mapping file is invalid. */ public void loadMapping(final String url, final String type) throws IOException, MappingException { String location = url; if (_resolver.getBaseURL() == null) { setBaseURL(location); location = URIUtils.getRelativeURI(location); } try { InputSource source = _resolver.resolveEntity(null, location); if (source == null) { source = new InputSource(location); } if (source.getSystemId() == null) { source.setSystemId(location); } LOG.info(Messages.format("mapping.loadingFrom", location)); loadMapping(source, type); } catch (SAXException ex) { throw new MappingException(ex); } }