/** * Copy a DOM node to create a node in a different tree model * * @param node the DOM node to be copied * @param model the target tree model * @param config the Saxon Configuration * @return the copied node * @throws net.sf.saxon.trans.XPathException * if the operation fails * @since 9.2 */ public NodeInfo copy(Node node, TreeModel model, Configuration config) throws XPathException { PipelineConfiguration pipe = config.makePipelineConfiguration(); Builder builder = model.makeBuilder(pipe); builder.open(); Sender.send(new DOMSource(node), builder, null); NodeInfo result = builder.getCurrentRoot(); builder.close(); return result; }
public void open() { if (timing && !open) { getConfiguration().getStandardErrorOutput().println( "Building tree for " + getSystemId() + " using " + getClass()); startTime = System.nanoTime(); } open = true; }
public void reset() { super.reset(); currentNode = null; nodeFactory = DefaultNodeFactory.THE_INSTANCE; depth = 0; allocateSequenceNumbers = true; nextNodeNumber = 1; }
public XdmNode getDocumentNode() throws SaxonApiException { try { builder.close(); } catch (XPathException e) { throw new SaxonApiException(e); } return new XdmNode(builder.getCurrentRoot()); } }
pipe.setParseOptions(options); Builder builder = treeModel.makeBuilder(pipe); builder.setTiming(isTiming()); builder.setLineNumbering(lineNumbering); builder.setPipelineConfiguration(pipe); builder.setSystemId(source.getSystemId()); Sender.send(source, new NamespaceReducer(builder), options); NodeInfo newdoc = builder.getCurrentRoot(); if (newdoc.getNodeKind() != Type.DOCUMENT) { throw new XPathException("Source object represents a node other than a document node"); builder.reset();
Builder builder = context.getController() .makeBuilder(); builder.open(); builder.startDocument(0); List<Block> l = hl.highlight(n2i .getStringValue()); blockToSaxon6Node(b, builder, c); builder.endDocument(); builder.close(); NodeInfo doc = builder.getCurrentRoot();
builder.setSystemId(sysId); final ExplicitLocation fixedLocation = new ExplicitLocation(sysId, -1, -1); ProxyReceiver filter = new ProxyReceiver(builder) { builder.open(); stylesheetNode.copy(filter, 0, ExplicitLocation.UNKNOWN_LOCATION); builder.close(); stylesheetNode = builder.getCurrentRoot();
b.setPipelineConfiguration(b.getPipelineConfiguration()); try { Sender.send(source, b, options); newdoc = b.getCurrentRoot().getTreeInfo(); b.reset(); } finally { if (options.isPleaseCloseAfterUse()) {
builder.setLineNumbering(controller.getConfiguration().isLineNumbering()); builder.setBaseURI(getBaseURI()); builder.setTiming(false); builder.setPipelineConfiguration(pipe); out.close(); root = (DocumentInfo)builder.getCurrentRoot(); } catch (XPathException e) { e.maybeSetLocation(this);
builder.setUseEventLocation(false); builder.setBaseURI(getStaticBaseURIString()); builder.setTiming(false); builder.setPipelineConfiguration(pipe); out.close(); context.setReceiver(saved); root = builder.getCurrentRoot(); } catch (XPathException e) { e.maybeSetLocation(getLocation());
s.setPipelineConfiguration(b.getPipelineConfiguration()); node = b.getCurrentRoot(); b.reset(); } catch (XPathException err) { XPathException xe = new XPathException("First argument to parse-xml-fragment() is not a well-formed and namespace-well-formed XML fragment. XML parser reported: " +
builder.setPipelineConfiguration(pipe); builder.setSystemId(systemId); builder.setBaseURI(systemId); builder.setTiming(false); builder.setUseEventLocation(false);
sourceBuilder.setUseEventLocation(true); if (sourceBuilder instanceof TinyBuilder) { ((TinyBuilder) sourceBuilder).setStatistics(config.getTreeStatistics().SOURCE_DOCUMENT_STATISTICS); r = config.getAnnotationStripper(r); PipelineConfiguration pipe = sourceBuilder.getPipelineConfiguration(); pipe.getParseOptions().setSchemaValidationMode(validationMode); r.setPipelineConfiguration(pipe); ((AugmentedSource) source).close(); NodeInfo doc = sourceBuilder.getCurrentRoot(); sourceBuilder.reset(); if (source.getSystemId() != null) { registerDocument(doc.getTreeInfo(), new DocumentURI(source.getSystemId()));
/** * Override the behaviour of endDocument() in ReceivingContentHandler, so that it fires off * the transformation of the constructed document */ public void endDocument() throws SAXException { super.endDocument(); DocumentInfo doc = (DocumentInfo)builder.getCurrentRoot(); builder.reset(); if (doc==null) { throw new SAXException("No source document has been built"); } try { controller.transformDocument(doc, result); } catch (TransformerException err) { if (err instanceof XPathException) { controller.reportFatalError((XPathException)err); } throw new SAXException(err); } }
public BuildingStreamWriterImpl(Receiver receiver, Builder builder) { super(receiver); this.builder = builder; builder.open(); }
public XdmNode getDocumentNode() { return new XdmNode(builder.getCurrentRoot()); } }
/** * Make a builder for the selected tree model. * * @return an instance of the Builder for the chosen tree model * @since 8.4 */ public Builder makeBuilder() { Builder b; if (treeModel==Builder.TINY_TREE) { b = new TinyBuilder(); } else { b = new TreeBuilder(); } b.setTiming(config.isTiming()); b.setLineNumbering(config.isLineNumbering()); b.setPipelineConfiguration(makePipelineConfiguration()); return b; }
/** * Create a TinyTree to hold a document or element node. * @throws net.sf.saxon.trans.XPathException */ private void createTree() throws XPathException { PipelineConfiguration pipe = getPipelineConfiguration(); builder = pipe.getController().makeBuilder(); builder.setPipelineConfiguration(pipe); builder.setSystemId(getSystemId()); builder.setTiming(false); NamespaceReducer reducer = new NamespaceReducer(); reducer.setUnderlyingReceiver(builder); reducer.setPipelineConfiguration(getPipelineConfiguration()); ComplexContentOutputter cco = new ComplexContentOutputter(); cco.setHostLanguage(getPipelineConfiguration().getHostLanguage()); cco.setPipelineConfiguration(getPipelineConfiguration()); cco.setReceiver(reducer); outputter = cco; outputter.setSystemId(systemId); outputter.setPipelineConfiguration(getPipelineConfiguration()); outputter.open(); }
/** * Callback interface for SAX: not for application use */ public void close () throws XPathException { // System.err.println("TreeBuilder: " + this + " End document"); if (currentNode==null) return; // can be called twice on an error path currentNode.compact(size[depth]); currentNode = null; // we're not going to use this Builder again so give the garbage collector // something to play with arrays = null; super.close(); nodeFactory = null; }
/** * Start of event stream */ public void open() throws XPathException { builder = controller.makeBuilder(); setPipelineConfiguration(builder.getPipelineConfiguration()); builder.setSystemId(systemId); Receiver stripper = controller.makeStripper(builder); if (controller.getExecutable().stripsInputTypeAnnotations()) { stripper = controller.getConfiguration().getAnnotationStripper(stripper); } setUnderlyingReceiver(stripper); nextReceiver.open(); }