public void cache(XdmNode doc, URI baseURI) { XdmNode root = S9apiUtils.getDocumentElement(doc); // We explicitly use the base URI of the root element so that if it has an xml:base // attribute, that becomes the base URI of the document. URI docURI = baseURI.resolve(root.getBaseURI()); if (useCache) { cache.put(docURI.toASCIIString(), doc); } }
public void cache(XdmNode doc, URI baseURI) { XdmNode root = S9apiUtils.getDocumentElement(doc); // We explicitly use the base URI of the root element so that if it has an xml:base // attribute, that becomes the base URI of the document. URI docURI = baseURI.resolve(root.getBaseURI()); if (useCache) { cache.put(docURI.toASCIIString(), doc); } }
public PipelineLibrary loadLibrary(InputStream libraryInputStream, String base) throws SaxonApiException, IOException { InputSource is = new InputSource(libraryInputStream); if (base != null) { is.setSystemId(base); } try { XdmNode doc = runtime.parse(is); XdmNode root = S9apiUtils.getDocumentElement(doc); return useLibrary(root); } finally { libraryInputStream.close(); } }
public PipelineLibrary loadLibrary(InputStream libraryInputStream, String base) throws SaxonApiException, IOException { InputSource is = new InputSource(libraryInputStream); if (base != null) { is.setSystemId(base); } try { XdmNode doc = runtime.parse(is); XdmNode root = S9apiUtils.getDocumentElement(doc); return useLibrary(root); } finally { libraryInputStream.close(); } }
public PrettyPrint(XProcRuntime runtime, XAtomicStep step) { super(runtime,step); if (prettyPrint == null) { try { InputStream instream = getClass().getResourceAsStream("/etc/prettyprint.xsl"); if (instream == null) { throw new UnsupportedOperationException("Failed to load prettyprint.xsl stylesheet from resources."); } XdmNode ppd = runtime.parse(new InputSource(instream)); prettyPrint = S9apiUtils.getDocumentElement(ppd); } catch (Exception e) { throw new XProcException(e); } } }
public PrettyPrint(XProcRuntime runtime, XAtomicStep step) { super(runtime,step); if (prettyPrint == null) { try { InputStream instream = getClass().getResourceAsStream("/etc/prettyprint.xsl"); if (instream == null) { throw new UnsupportedOperationException("Failed to load prettyprint.xsl stylesheet from resources."); } XdmNode ppd = runtime.parse(new InputSource(instream)); prettyPrint = S9apiUtils.getDocumentElement(ppd); } catch (Exception e) { throw new XProcException(e); } } }
private XdmNode loadExtensionLibrary() throws FileNotFoundException, URISyntaxException, SaxonApiException { URI home = URIUtils.homeAsURI(); URI puri = home; InputStream instream = getClass().getResourceAsStream("/etc/extension-library.xml"); if (instream == null) { throw new UnsupportedOperationException("Failed to load XProc pipeline library from JAR file"); } XdmNode doc = parse(instream, puri); XdmNode root = S9apiUtils.getDocumentElement(doc); if (!XProcConstants.p_library.equals(root.getNodeName())) { throw new UnsupportedOperationException("Pipeline libraries must be p:library documents"); } return doc; }
private XdmNode loadExtensionLibrary() throws FileNotFoundException, URISyntaxException, SaxonApiException { URI home = URIUtils.homeAsURI(); URI puri = home; InputStream instream = getClass().getResourceAsStream("/etc/extension-library.xml"); if (instream == null) { throw new UnsupportedOperationException("Failed to load XProc pipeline library from JAR file"); } XdmNode doc = parse(instream, puri); XdmNode root = S9apiUtils.getDocumentElement(doc); if (!XProcConstants.p_library.equals(root.getNodeName())) { throw new UnsupportedOperationException("Pipeline libraries must be p:library documents"); } return doc; }
public PipelineLibrary loadLibrary(String libraryURI) throws SaxonApiException { XdmNode doc = runtime.parse(libraryURI, URIUtils.cwdAsURI().toASCIIString()); XdmNode root = S9apiUtils.getDocumentElement(doc); return useLibrary(root); }
public PipelineLibrary loadLibrary(String libraryURI) throws SaxonApiException { XdmNode doc = runtime.parse(libraryURI, URIUtils.cwdAsURI().toASCIIString()); XdmNode root = S9apiUtils.getDocumentElement(doc); return useLibrary(root); }
public DeclareStep usePipeline(XdmNode node) { if (node.getNodeKind() == XdmNodeKind.DOCUMENT) { node = S9apiUtils.getDocumentElement(node); } DeclareStep decl = readDeclareStep(node); parseDeclareStepBodyPassTwo(decl); return decl; }
public DeclareStep usePipeline(XdmNode node) { if (node.getNodeKind() == XdmNodeKind.DOCUMENT) { node = S9apiUtils.getDocumentElement(node); } DeclareStep decl = readDeclareStep(node); parseDeclareStepBodyPassTwo(decl); return decl; }
public PipelineLibrary loadStandardLibrary() throws FileNotFoundException, URISyntaxException, SaxonApiException { URI home = URIUtils.homeAsURI(); URI cwd = URIUtils.cwdAsURI(); URI puri = home; InputStream instream = getClass().getResourceAsStream("/etc/pipeline-library.xml"); if (instream == null) { throw new UnsupportedOperationException("Failed to load standard pipeline library from JAR file"); } XdmNode doc = parse(instream, puri); XdmNode root = S9apiUtils.getDocumentElement(doc); if (!XProcConstants.p_library.equals(root.getNodeName())) { throw new UnsupportedOperationException("Pipeline libraries must be p:library documents"); } loadingStandardLibrary = true; PipelineLibrary library = readLibrary(null, root); loadingStandardLibrary = false; return library; }
public PipelineLibrary loadStandardLibrary() throws FileNotFoundException, URISyntaxException, SaxonApiException { URI home = URIUtils.homeAsURI(); URI cwd = URIUtils.cwdAsURI(); URI puri = home; InputStream instream = getClass().getResourceAsStream("/etc/pipeline-library.xml"); if (instream == null) { throw new UnsupportedOperationException("Failed to load standard pipeline library from JAR file"); } XdmNode doc = parse(instream, puri); XdmNode root = S9apiUtils.getDocumentElement(doc); if (!XProcConstants.p_library.equals(root.getNodeName())) { throw new UnsupportedOperationException("Pipeline libraries must be p:library documents"); } loadingStandardLibrary = true; PipelineLibrary library = readLibrary(null, root); loadingStandardLibrary = false; return library; }
private DeclareStep loadPipeline(XdmNode doc) throws SaxonApiException { XdmNode root = S9apiUtils.getDocumentElement(doc); if (!XProcConstants.p_declare_step.equals(root.getNodeName()) && !XProcConstants.p_pipeline.equals(root.getNodeName())) { throw new UnsupportedOperationException("Pipelines must be p:pipeline or p:declare-step documents"); } return usePipeline(root); }
private DeclareStep loadPipeline(XdmNode doc) throws SaxonApiException { XdmNode root = S9apiUtils.getDocumentElement(doc); if (!XProcConstants.p_declare_step.equals(root.getNodeName()) && !XProcConstants.p_pipeline.equals(root.getNodeName())) { throw new UnsupportedOperationException("Pipelines must be p:pipeline or p:declare-step documents"); } return usePipeline(root); }
public XMLLocation(Step step, XdmNode node) { if (step != null) { type = step.getDeclaredType(); } if (node != null) { URI cwd = URIUtils.cwdAsURI(); systemId = cwd.relativize(node.getBaseURI()).toASCIIString(); line = node.getLineNumber(); if (line <= 0) { line = S9apiUtils.getDocumentElement(node).getLineNumber(); } col = node.getColumnNumber(); } }
@BeforeClass public static void setupClass() throws Exception { String xml = "<document><?foo?><p>A paragraph</p> <p>A paragraph</p> some text "; xml += "<p>Another paragraph</p><!--comment-->"; xml += "<documentation xmlns='http://www.w3.org/ns/xproc'>some doc</documentation></document>"; DocumentBuilder builder = processor.newDocumentBuilder(); root = S9apiUtils.getDocumentElement(builder.build(new SAXSource(new InputSource(new StringReader(xml))))); }
public void run() throws SaxonApiException { super.run(); root = S9apiUtils.getDocumentElement(attributes.read()); attrs = new HashSet<QName> (); XdmSequenceIterator iter = root.axisIterator(Axis.ATTRIBUTE); while (iter.hasNext()) { XdmNode attr = (XdmNode) iter.next(); attrs.add(attr.getNodeName()); } matcher = new ProcessMatch(runtime, this); matcher.match(source.read(), getOption(_match)); if (source.moreDocuments()) { throw XProcException.dynamicError(6, "Reading source on " + getStep().getName()); } result.write(matcher.getResult()); }
public void run() throws SaxonApiException { super.run(); root = S9apiUtils.getDocumentElement(attributes.read()); attrs = new HashSet<QName> (); XdmSequenceIterator iter = root.axisIterator(Axis.ATTRIBUTE); while (iter.hasNext()) { XdmNode attr = (XdmNode) iter.next(); attrs.add(attr.getNodeName()); } matcher = new ProcessMatch(runtime, this); matcher.match(source.read(), getOption(_match)); if (source.moreDocuments()) { throw XProcException.dynamicError(6, "Reading source on " + getStep().getName()); } result.write(matcher.getResult()); }