/** * Creates a pooling Parser with the given options, using the global DocumentBuilder pool. * * @param options * the options. * @return DOMParser. */ public static DOMParser createPoolingParser(final DOMParserOptions options) { return new PoolingDOMParser(options != null ? options : DOMParserOptions.getDefault(), getDocumentBuilderPool()); }
/** * @return the xPathPool */ private static XPathPool getGlobalXPathPool() { if (xPathPool == null) { xPathPool = new XPathPool(createXPathFactory()); } return xPathPool; }
/** * Creates a non pooling Parser, with the given options. * * @param options * the options. * @return DOMParser. */ public static DOMParser createNonPoolingParser(final DOMParserOptions options) { return new NonPoolingDOMParser(options != null ? options : DOMParserOptions.getDefault()); }
private Node find(final String xpath) { Node node = XMLPathCtx.createNew().addNamespaces(namespaces).findIn(sourceDocument).node(xpath).get(); if (node == null) { throw new IllegalArgumentException("XPath <" + xpath + "> must resolve to an node"); } return (Element) node; }
@Override public void write(String charset, Map<String, Iterable<String>> header, OutputStream outstream) throws IOException { DOMSerializer serializer = DOMSerializer.createNew(DOMSerializerOptions.getDefaultOptions().encoding(charset)); serializer.serialize(m_xmlContent, outstream); }
private void buildExtentTemplate(Document document, Map<String, String> hashMap, XMLPathCtx xmlPathCtx) { hashMap.put("west", xmlPathCtx.findIn(document).text("//gmd:westBoundLongitude/*/text()").get()); hashMap.put("east", xmlPathCtx.findIn(document).text("//gmd:eastBoundLongitude/*/text()").get()); hashMap.put("north", xmlPathCtx.findIn(document).text("//gmd:northBoundLatitude/*/text()").get()); hashMap.put("south", xmlPathCtx.findIn(document).text("//gmd:southBoundLatitude/*/text()").get()); }
/** * Parses the inputsource and informs the error handler about errors. * * @throws DOMParserException * if an SAXException or IOException occurs. */ public Document parse(final InputSource inputSource, final ErrorHandler errorhandler) throws DOMParserException { return parse(inputSource, errorhandler, getDefaultEntityResolver()); }
public static Document createEmptyDocument(final DOMParserOptions options) { DOMParserOptions opts = options != null ? options : DOMParserOptions.getDefault(); DocumentBuilderPool pool = getDocumentBuilderPool(); DocumentBuilder builder = pool.acquire(opts); try { return builder.newDocument(); } finally { pool.release(builder, opts); } }
public static DOMSerializer createNew(final DOMSerializerOptions options) { return new PoolingDOMSerializer(options == null ? DOMSerializerOptions.getDefaultOptions() : options, copyTransformerPool); }
private XMLChunk endChunk() throws XMLStreamException { Chunk chunk = m_chunkStack.removeFirst(); String content = chunk.getWriter().getChunkContent(); m_chunkWriterPool.release(chunk.getWriter()); Chunk parentChunk = m_chunkStack.isEmpty() ? null : m_chunkStack.getFirst(); return new XMLChunk(false, chunk.getXmlChunk().getXpath(), content, parentChunk != null ? parentChunk.getXmlChunk() : null); }
/** * Method toLSInput converts a InputSource to a LSInput. * * @param inputSource the inputSource. * @return LSInput. */ private LSInput toLSInput(final InputSource inputSource, String baseUri) { return new LSInputSourceAdapter(inputSource, baseUri); } }
/** * Creates a non pooling Parser, with default options. * * @return DOMParser. */ public static DOMParser createNonPoolingParser() { return createNonPoolingParser(null); }
/** * Parses the inputsource. * * @throws DOMParserException * if an SAXException or IOException occurs. */ public Document parse(final InputSource inputSource) throws DOMParserException { return parse(inputSource, null, getDefaultEntityResolver()); } }
/** * Creates a pooling Parser with the given options, which uses the given document builder pool. * * @return DOMParser. */ public static DOMParser createPoolingParser(final DOMParserOptions options, final DocumentBuilderPool pool) { return new PoolingDOMParser(options != null ? options : DOMParserOptions.getDefault(), pool != null ? pool : getDocumentBuilderPool()); }