/** * Get an {@link org.xml.sax.ContentHandler} that may be used to build the document programmatically. * * @return a newly constructed {@link BuildingContentHandler}, which implements the <code>ContentHandler</code> * interface. If schema validation has been requested for this <code>DocumentBuilder</code>, then the document constructed * using the <code>ContentHandler</code> will be validated as it is written. * <p>Note that the returned <code>ContentHandler</code> expects namespace scopes to be indicated * explicitly by calls to {@link org.xml.sax.ContentHandler#startPrefixMapping} and * {@link org.xml.sax.ContentHandler#endPrefixMapping}.</p> * <p>If the stream of events supplied to the <code>ContentHandler</code> does not constitute * a well formed (and namespace-well-formed) document, the effect is undefined; Saxon may fail * to detect the error, and construct an unusable tree. </p> * @throws SaxonApiException if any failure occurs * @since 9.3 */ public BuildingContentHandler newBuildingContentHandler() throws SaxonApiException { PipelineConfiguration pipe = config.makePipelineConfiguration(); Builder builder = treeModel.makeBuilder(pipe); if (baseURI != null) { builder.setSystemId(baseURI.toASCIIString()); } builder.setLineNumbering(lineNumbering); Receiver r = builder; r = new NamespaceReducer(r); r = injectValidator(r, builder); return new BuildingContentHandlerImpl(r, builder); }
/** * Get an {@link javax.xml.stream.XMLStreamWriter} that may be used to build the document programmatically. * * @return a newly constructed {@link BuildingStreamWriter}, which implements the <code>XMLStreamWriter</code> * interface. If schema validation has been requested for this <code>DocumentBuilder</code>, then the document constructed * using the <code>XMLStreamWriter</code> will be validated as it is written. * <p>If the stream of events supplied to the <code>XMLStreamWriter</code> does not constitute * a well formed (and namespace-well-formed) document, the effect is undefined; Saxon may fail * to detect the error, and construct an unusable tree. </p> * @throws SaxonApiException if any failure occurs * @since 9.3 */ public BuildingStreamWriterImpl newBuildingStreamWriter() throws SaxonApiException { PipelineConfiguration pipe = config.makePipelineConfiguration(); Builder builder = treeModel.makeBuilder(pipe); builder.setLineNumbering(lineNumbering); Receiver r = builder; r = new NamespaceReducer(r); r = injectValidator(r, builder); return new BuildingStreamWriterImpl(r, builder); }