Debian Codegraph @

net/sf/saxon/s9api/DOMDestination.java

raw symbols SCIP
1 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2018 Saxonica Limited.
3 // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4 // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
6 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7
8 package net.sf.saxon.s9api;
9
10 import net.sf.saxon.dom.DOMWriter;
11 import net.sf.saxon.event.PipelineConfiguration;
12 import net.sf.saxon.event.Receiver;
13 import net.sf.saxon.serialize.SerializationProperties;
14
15 /**
16 * This class represents a Destination (for example, the destination of the output of a transformation)
17 * in which the results are written to a newly constructed DOM tree in memory. The caller must supply
18 * a Document node, which will be used as the root of the constructed tree
19 */
20
21 public class DOMDestination extends AbstractDestination {
22
23 private DOMWriter domWriter;
24
25 /**
26 * Create a DOMDestination, supplying a node in a DOM document to which the
27 * content of the result tree will be attached.
28 *
29 * @param root the root node for the new tree. This must be a document or element node.
30 */
31
32 public DOMDestination(org.w3c.dom.Node root) {
33 domWriter = new DOMWriter();
34 domWriter.setNode(root);
35 }
36
37 /**
38 * Return a Receiver. Saxon calls this method to obtain a Receiver, to which it then sends
39 * a sequence of events representing the content of an XML document.
40 *
41 * @param pipe The Saxon configuration. This is supplied so that the destination can
42 * use information from the configuration (for example, a reference to the name pool)
43 * to construct or configure the returned Receiver.
44 * @param params
45 * @return the Receiver to which events are to be sent.
46 */
47
48 public Receiver getReceiver(/*@NotNull*/ PipelineConfiguration pipe, SerializationProperties params) {
49 domWriter.setPipelineConfiguration(pipe);
50 return params.makeSequenceNormalizer(domWriter);
51 }
52
53 /**
54 * Close the destination, allowing resources to be released. Saxon calls this method when
55 * it has finished writing to the destination.
56 */
57
58 public void close() throws SaxonApiException {
59 // no action
60 }
61 }