/** * Build a document from a supplied XML file * * @param file the supplied file * @return the XdmNode representing the root of the document tree * @throws SaxonApiException if any failure occurs retrieving or parsing the document */ public XdmNode build(File file) throws SaxonApiException { return build(new StreamSource(file)); }
/** * Build a document from a supplied XML file * * @param file the supplied file * @return the XdmNode representing the root of the document tree * @throws SaxonApiException if any failure occurs retrieving or parsing the document */ public XdmNode build(File file) throws SaxonApiException { return build(new StreamSource(file)); }
/** * Build a document from a supplied XML file * @param file the supplied file * @return the XdmNode representing the root of the document tree * @throws SaxonApiException if any failure occurs retrieving or parsing the document */ public XdmNode build(File file) throws SaxonApiException { return build(new StreamSource(file)); }
private List<XdmNode> createXdmNodes(List<File> spotBugsFiles, DocumentBuilder documentBuilder) { return spotBugsFiles.stream().map(t -> { try { return documentBuilder.build(t); } catch (SaxonApiException e) { LOG.error(e.getMessage(), e); } return null; }).collect(Collectors.toList()); } }
public static XdmNode getParamsFromLog( net.sf.saxon.s9api.DocumentBuilder builder, Document log) throws Exception { Element starttest = (Element) log.getElementsByTagName("starttest") .item(0); NodeList nl = starttest.getElementsByTagName("params"); if (nl == null || nl.getLength() == 0) { return null; } else { Document doc = DomUtils.createDocument(nl.item(0)); return builder.build(new DOMSource(doc)); } }
private void loadConfigurationFile(XProcConfiguration conf, InputStream config) { SAXSource source = new SAXSource(new InputSource(config)); DocumentBuilder builder = conf.getProcessor().newDocumentBuilder(); XdmNode doc; try { doc = builder.build(source); } catch (SaxonApiException e) { logger.error("Error loading configuration file", e); throw new RuntimeException("error loading configuration file", e); } conf.parse(doc); }
/** * Set the source document for the transformation. This method is equivalent to building * a document from the supplied source object, and then supplying the document node of * the resulting document as the initial context node. * @param source the principal source document for the transformation */ public void setSource(Source source) throws SaxonApiException { setInitialContextNode(processor.newDocumentBuilder().build(source)); }
/** * Set the source document for the query. This method is equivalent to building * a document from the supplied source object, and then supplying the document node of * the resulting document as the initial context node. * @param source the principal source document for the transformation */ public void setSource(Source source) throws SaxonApiException { setContextItem(processor.newDocumentBuilder().build(source)); }
private XdmNode buildXdmNode(Source s, URI baseURI) throws SaxonApiException { DocumentBuilder builder = processor.newDocumentBuilder(); builder.setBaseURI(baseURI); return builder.build(s); }
private Iterable<XdmItem> getIterableXpathResult(String source, LogicalSource logicalSource) { DocumentBuilder documentBuilder = xpathProcessor.newDocumentBuilder(); StringReader reader = new StringReader(source); setNamespaces(logicalSource); try { XdmNode item = documentBuilder.build(new StreamSource(reader)); XPathSelector selector = xpath.compile(logicalSource.getIterator()).load(); selector.setContextItem(item); return selector; } catch (SaxonApiException e) { throw new RuntimeException(e); } }
@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))))); }
private void setTemplate(final InputStream templateInputStream, final Processor processor, final XMLReader xmlReader, final XsltTransformer xsltTransformer) throws SaxonApiException { InputSource inputSource = inputSourceFactory.createInputSource(templateInputStream); Source templateSource = saxSourceFactory.createSAXSource(xmlReader, inputSource); XdmNode templateNode = processor.newDocumentBuilder().build(templateSource); xsltTransformer.setInitialContextNode(templateNode); }
private void setParameter(final InputStream parameterInputStream, final Processor processor, final XsltTransformer xsltTransformer, final String parameterName) throws SaxonApiException { StreamSource requestStreamSource = streamSourceFactory.createStreamSource(parameterInputStream); XdmNode requestDocument = processor.newDocumentBuilder().build(requestStreamSource); QName parameter = qNameFactory.createQName(parameterName); xsltTransformer.setParameter(parameter, requestDocument); }
private void setRequest(final InputStream requestInputStream, final Processor processor, final XsltTransformer xsltTransformer) throws SaxonApiException { StreamSource requestStreamSource = streamSourceFactory.createStreamSource(requestInputStream); XdmNode requestDocument = processor.newDocumentBuilder().build(requestStreamSource); QName requestName = qNameFactory.createQName(REQUEST_PARAMETER_NAME); xsltTransformer.setParameter(requestName, requestDocument); }
private void setTemplate(final InputStream templateInputStream, final Processor processor, final XMLReader xmlReader, final XsltTransformer xsltTransformer) throws SaxonApiException { InputSource inputSource = inputSourceFactory.createInputSource(templateInputStream); Source templateSource = saxSourceFactory.createSAXSource(xmlReader, inputSource); XdmNode templateNode = processor.newDocumentBuilder().build(templateSource); xsltTransformer.setInitialContextNode(templateNode); }
public void run() throws SaxonApiException { Processor saxon = new Processor(false); XProcConfiguration config = new XProcConfiguration(saxon); XProcRuntime runtime = new XProcRuntime(config); InputStream stream = new ByteArrayInputStream(pipeline_xml.getBytes()); DocumentBuilder builder = saxon.newDocumentBuilder(); XdmNode pipeline_doc = builder.build(new SAXSource(new InputSource(stream))); XPipeline pipeline = runtime.use(pipeline_doc); pipeline.run(); }
private void givenParameter(final String parameterName, final QName qName) throws SaxonApiException { given(streamSourceFactory.createStreamSource(requestInputStream)).willReturn(new StreamSource()); given(processor.newDocumentBuilder().build(any(StreamSource.class))).willReturn(requestDocument); given(qNameFactory.createQName(parameterName)).willReturn(qName); }
private void setTemplateMocks() throws SaxonApiException { given(inputSourceFactory.createInputSource(templateInputStream)).willReturn(inputSource); given(saxSourceFactory.createSAXSource(xmlReader, inputSource)).willReturn(templateSource); given(processor.newDocumentBuilder().build(templateSource)).willReturn(templateNode); } }
private void setRequestMocks() throws SaxonApiException { given(streamSourceFactory.createStreamSource(requestInputStream)).willReturn(requestStreamResource); given(processor.newDocumentBuilder().build(requestStreamResource)).willReturn(requestDocument); given(qNameFactory.createQName("request")).willReturn(requestName); }
private void setTemplateMocks() throws SaxonApiException { given(inputSourceFactory.createInputSource(templateInputStream)).willReturn(inputSource); given(saxSourceFactory.createSAXSource(xmlReader, inputSource)).willReturn(templateSource); given(processor.newDocumentBuilder().build(templateSource)).willReturn(templateNode); } }