Package com.icl.saxon.jdom
Class NodeWrapper
- java.lang.Object
-
- com.icl.saxon.jdom.NodeWrapper
-
- All Implemented Interfaces:
NodeInfo,javax.xml.transform.Source
- Direct Known Subclasses:
DocumentWrapper
public class NodeWrapper extends java.lang.Object implements NodeInfo
A node in the XML parse tree representing an XML element, character content, or attribute.This is the top class in the interface hierarchy for nodes; see NodeImpl for the implementation hierarchy.
- Author:
- Michael H. Kay
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classNodeWrapper.AncestorEnumeration
-
Field Summary
Fields Modifier and Type Field Description protected DocumentWrapperdocWrapperprotected intindexprotected java.lang.Objectnodeprotected shortnodeTypeprotected NodeWrapperparent
-
Constructor Summary
Constructors Constructor Description NodeWrapper(java.lang.Object node, NodeWrapper parent, int index)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareOrder(NodeInfo other)Determine the relative position of this node and another node, in document order.voidcopy(Outputter out)Copy this node to a given outputter (deep copy)voidcopyStringValue(Outputter out)Copy the string-value of this node to a given outputterjava.lang.StringgenerateId()Get a character string that uniquely identifies this node.
Note: a.isSameNode(b) if and only if generateId(a)==generateId(b)java.lang.StringgetAttributeValue(int fingerprint)Get the value of a given attribute of this nodejava.lang.StringgetAttributeValue(java.lang.String uri, java.lang.String localName)Find the value of a given attribute of this node.java.lang.StringgetBaseURI()Get the Base URI for the node, that is, the URI used for resolving a relative URI contained in the node.java.lang.StringgetDisplayName()Get the display name of this node.DocumentInfogetDocumentRoot()Get the root (document) nodeAxisEnumerationgetEnumeration(byte axisNumber, NodeTest nodeTest)Return an enumeration over the nodes reached by the given axis from this nodeintgetFingerprint()Get fingerprint.intgetLineNumber()Get line numberjava.lang.StringgetLocalName()Get the local part of the name of this node.intgetNameCode()Get name code.java.lang.ObjectgetNode()Get the underlying JDOM nodeshortgetNodeType()Return the type of node.NodeInfogetParent()Get the NodeInfo object representing the parent of this nodejava.lang.StringgetPrefix()Get the prefix part of the name of this node.java.lang.StringgetStringValue()Return the string value of the node.java.lang.StringgetSystemId()Get the System ID for the node.java.lang.StringgetURI()Get the URI part of the name of this node.booleanhasChildNodes()Determine whether the node has any children.booleanisSameNodeInfo(NodeInfo other)Determine whether this is the same node as another node.NodeWrappermakeWrapper(java.lang.Object node, NodeWrapper parent, int index)voidoutputNamespaceNodes(Outputter out, boolean includeAncestors)Output all namespace nodes associated with this element.voidsetSystemId(java.lang.String uri)
-
-
-
Field Detail
-
node
protected java.lang.Object node
-
nodeType
protected short nodeType
-
parent
protected NodeWrapper parent
-
docWrapper
protected DocumentWrapper docWrapper
-
index
protected int index
-
-
Constructor Detail
-
NodeWrapper
public NodeWrapper(java.lang.Object node, NodeWrapper parent, int index)
-
-
Method Detail
-
makeWrapper
public NodeWrapper makeWrapper(java.lang.Object node, NodeWrapper parent, int index)
-
getNode
public java.lang.Object getNode()
Get the underlying JDOM node
-
getNodeType
public short getNodeType()
Return the type of node.- Specified by:
getNodeTypein interfaceNodeInfo- Returns:
- one of the values Node.ELEMENT, Node.TEXT, Node.ATTRIBUTE, etc.
-
isSameNodeInfo
public boolean isSameNodeInfo(NodeInfo other)
Determine whether this is the same node as another node.
Note: a.isSameNode(b) if and only if generateId(a)==generateId(b)- Specified by:
isSameNodeInfoin interfaceNodeInfo- Returns:
- true if this Node object and the supplied Node object represent the same node in the tree.
-
getSystemId
public java.lang.String getSystemId()
Get the System ID for the node.- Specified by:
getSystemIdin interfaceNodeInfo- Specified by:
getSystemIdin interfacejavax.xml.transform.Source- Returns:
- the System Identifier of the entity in the source document containing the node, or null if not known. Note this is not the same as the base URI: the base URI can be modified by xml:base, but the system ID cannot.
-
setSystemId
public void setSystemId(java.lang.String uri)
- Specified by:
setSystemIdin interfacejavax.xml.transform.Source
-
getBaseURI
public java.lang.String getBaseURI()
Get the Base URI for the node, that is, the URI used for resolving a relative URI contained in the node. This will be the same as the System ID unless xml:base has been used.- Specified by:
getBaseURIin interfaceNodeInfo
-
getLineNumber
public int getLineNumber()
Get line number- Specified by:
getLineNumberin interfaceNodeInfo- Returns:
- the line number of the node in its original source document; or -1 if not available
-
compareOrder
public int compareOrder(NodeInfo other)
Determine the relative position of this node and another node, in document order. The other node will always be in the same document.- Specified by:
compareOrderin interfaceNodeInfo- Parameters:
other- The other node, whose position is to be compared with this node- Returns:
- -1 if this node precedes the other node, +1 if it follows the other node, or 0 if they are the same node. (In this case, isSameNode() will always return true, and the two nodes will produce the same result for generateId())
-
getStringValue
public java.lang.String getStringValue()
Return the string value of the node. The interpretation of this depends on the type of node. For an element it is the accumulated character content of the element, including descendant elements.- Specified by:
getStringValuein interfaceNodeInfo- Returns:
- the string value of the node
-
getNameCode
public int getNameCode()
Get name code. The name code is a coded form of the node name: two nodes with the same name code have the same namespace URI, the same local name, and the same prefix. By masking the name code with &0xfffff, you get a fingerprint: two nodes with the same fingerprint have the same local name and namespace URI.- Specified by:
getNameCodein interfaceNodeInfo- See Also:
allocate
-
getFingerprint
public int getFingerprint()
Get fingerprint. The fingerprint is a coded form of the expanded name of the node: two nodes with the same name code have the same namespace URI and the same local name. A fingerprint of -1 should be returned for a node with no name.- Specified by:
getFingerprintin interfaceNodeInfo
-
getLocalName
public java.lang.String getLocalName()
Get the local part of the name of this node. This is the name after the ":" if any.- Specified by:
getLocalNamein interfaceNodeInfo- Returns:
- the local part of the name. For an unnamed node, return an empty string.
-
getPrefix
public java.lang.String getPrefix()
Get the prefix part of the name of this node. This is the name before the ":" if any.
-
getURI
public java.lang.String getURI()
Get the URI part of the name of this node. This is the URI corresponding to the prefix, or the URI of the default namespace if appropriate.
-
getDisplayName
public java.lang.String getDisplayName()
Get the display name of this node. For elements and attributes this is [prefix:]localname. For unnamed nodes, it is an empty string.- Specified by:
getDisplayNamein interfaceNodeInfo- Returns:
- The display name of this node. For a node with no name, return an empty string.
-
getParent
public NodeInfo getParent()
Get the NodeInfo object representing the parent of this node
-
getEnumeration
public AxisEnumeration getEnumeration(byte axisNumber, NodeTest nodeTest)
Return an enumeration over the nodes reached by the given axis from this node- Specified by:
getEnumerationin interfaceNodeInfo- Parameters:
nodeTest- the type(s) of node to be included, e.g. NodeInfo.ELEMENT, NodeInfo.TEXT. The value NodeInfo.NODE means include any type of node.nodeTest- A pattern to be matched by the returned nodesaxisNumber- the axis to be followed (a constant in classAxis)- Returns:
- a NodeEnumeration that scans the nodes reached by the axis in turn.
-
getAttributeValue
public java.lang.String getAttributeValue(java.lang.String uri, java.lang.String localName)Find the value of a given attribute of this node.
This method is defined on all nodes to meet XSL requirements, but for nodes other than elements it will always return null.- Specified by:
getAttributeValuein interfaceNodeInfo- Parameters:
uri- the namespace uri of an attribute ("" if no namespace)localName- the local name of the attribute- Returns:
- the value of the attribute, if it exists, otherwise null
-
getAttributeValue
public java.lang.String getAttributeValue(int fingerprint)
Get the value of a given attribute of this node- Specified by:
getAttributeValuein interfaceNodeInfo- Parameters:
fingerprint- The fingerprint of the attribute name- Returns:
- the attribute value if it exists or null if not
-
getDocumentRoot
public DocumentInfo getDocumentRoot()
Get the root (document) node- Specified by:
getDocumentRootin interfaceNodeInfo- Returns:
- the DocumentInfo representing the containing document
-
hasChildNodes
public boolean hasChildNodes()
Determine whether the node has any children.
Note: the result is equivalent to
getEnumeration(Axis.CHILD, AnyNodeTest.getInstance()).hasMoreElements()- Specified by:
hasChildNodesin interfaceNodeInfo
-
generateId
public java.lang.String generateId()
Get a character string that uniquely identifies this node.
Note: a.isSameNode(b) if and only if generateId(a)==generateId(b)- Specified by:
generateIdin interfaceNodeInfo- Returns:
- a string that uniquely identifies this node, within this document. The calling code prepends information to make the result unique across all documents.
-
copy
public void copy(Outputter out) throws javax.xml.transform.TransformerException
Copy this node to a given outputter (deep copy)
-
copyStringValue
public void copyStringValue(Outputter out) throws javax.xml.transform.TransformerException
Copy the string-value of this node to a given outputter- Specified by:
copyStringValuein interfaceNodeInfo- Throws:
javax.xml.transform.TransformerException
-
outputNamespaceNodes
public void outputNamespaceNodes(Outputter out, boolean includeAncestors) throws javax.xml.transform.TransformerException
Output all namespace nodes associated with this element. Does nothing if the node is not an element.- Specified by:
outputNamespaceNodesin interfaceNodeInfo- Parameters:
out- The relevant outputterincludeAncestors- True if namespaces declared on ancestor elements must be output; false if it is known that these are already on the result tree- Throws:
javax.xml.transform.TransformerException
-
-