public class SaplingDocument extends SaplingNode implements ActiveSource
Like all sapling nodes, a SaplingDocument
is immutable. All operations such as adding children
deliver a new document node. A sapling node generally exists only transiently during tree
construction; to make use of the constructed tree, it will usually be converted to a regular tree when
construction is complete, using toXdmNode(Processor)
or toNodeInfo(Configuration)
.
SaplingDocument
implements Source
, and a sapling document
can therefore be supplied in most Saxon interfaces that expect a Source. However, third-party software
that expects a Source
as input is unlikely to recognize this class, unless explicitly
stated to the contrary.
Constructor and Description |
---|
SaplingDocument()
Create a sapling document node with no children and no base URI
|
SaplingDocument(java.lang.String baseUri)
Create a sapling document node with no children, having a specified base URI
|
Modifier and Type | Method and Description |
---|---|
void |
deliver(Receiver receiver,
ParseOptions options)
Send a sequence of events representing this node to a supplied Receiver
|
int |
getNodeKind()
Get the kind of node (document, element, text, comment, or processing instruction)
|
java.lang.String |
getSystemId()
Get the system identifier.
|
void |
send(Processor processor,
Destination destination)
Send the document to an arbitrary destination
|
void |
serialize(Serializer serializer)
Serialize the document
|
void |
setSystemId(java.lang.String systemId)
Set the system identifier for this Source.
|
NodeInfo |
toNodeInfo(Configuration config)
Convert the sapling document to a regular document, returning the
NodeInfo object
representing the document node of the resulting tree |
XdmNode |
toXdmNode(Processor processor)
Convert the sapling document to a regular document, returning the
XdmNode object
representing the document node of the resulting tree |
SaplingDocument |
withChild(SaplingNode... children)
Add a number of child nodes to a document node, returning a new document node
with additional children beyond those already present.
|
emptyNodeList
public SaplingDocument()
public SaplingDocument(java.lang.String baseUri)
baseUri
- the base URI of the document nodepublic void setSystemId(java.lang.String systemId)
Source
interface; however
it always throws an exception, because SaplingDocument
is immutable.setSystemId
in interface javax.xml.transform.Source
systemId
- The system identifier as a URL string.java.lang.UnsupportedOperationException
- alwayspublic java.lang.String getSystemId()
getSystemId
in interface javax.xml.transform.Source
public int getNodeKind()
SaplingNode
getNodeKind
in class SaplingNode
Type.ELEMENT
for an element node.public SaplingDocument withChild(SaplingNode... children)
children
- The nodes to be added as children.
The supplied nodes are added in order after any existing children.java.lang.IllegalArgumentException
- if any of the nodes supplied as an argument is
a document node.public void deliver(Receiver receiver, ParseOptions options) throws XPathException
SaplingNode
deliver
in interface ActiveSource
deliver
in class SaplingNode
receiver
- the receiver to which the events are to be sentoptions
- parse options (currently ignored)XPathException
- if the receiver throws an exceptionpublic NodeInfo toNodeInfo(Configuration config) throws XPathException
NodeInfo
object
representing the document node of the resulting treeconfig
- the Saxon ConfigurationXPathException
- if construction fails; this could happen if constraints have been violatedpublic XdmNode toXdmNode(Processor processor) throws SaxonApiException
XdmNode
object
representing the document node of the resulting treeprocessor
- the s9api Processor object that is to own the resulting treeSaxonApiException
- if construction fails; this could happen if constraints have been violatedpublic void serialize(Serializer serializer) throws SaxonApiException
serializer
- the serializer to be used; the serialized representation of the node
will be written to the serializer's destination.SaxonApiException
- if anything goes wrongpublic void send(Processor processor, Destination destination) throws SaxonApiException
processor
- the s9api processordestination
- the destination to which the document will be copied.SaxonApiException
- if anything goes wrongCopyright (c) 2004-2022 Saxonica Limited. All rights reserved.