org.apache.xpath
Class DOMHelper

java.lang.Object
  |
  +--org.apache.xpath.DOMHelper
Direct Known Subclasses:
DOM2Helper

public class DOMHelper
extends java.lang.Object


Constructor Summary
DOMHelper()
           
 
Method Summary
 Document createDocument()
          Used as a helper for handling DOM issues.
 Document getDOMFactory()
          Get the factory object required to create DOM nodes in the result tree.
 Element getElementByID(java.lang.String id, Document doc)
          Given an ID, return the element.
 java.lang.String getExpandedAttributeName(Attr attr)
          Returns the attribute name with the namespace expanded.
 java.lang.String getExpandedElementName(Element elem)
          Returns the element name with the namespace expanded.
 short getLevel(Node n)
          **For internal use only** Get the depth level of this node in the tree (count from 1).
 java.lang.String getLocalNameOfNode(Node n)
          Returns the local name of the given node.
 java.lang.String getNamespaceForPrefix(java.lang.String prefix, Element namespaceContext)
          Given a prefix and a namespace context, return the expanded namespace.
 java.lang.String getNamespaceOfNode(Node n)
          Returns the namespace of the given node.
static java.lang.String getNodeData(Node node)
          Get the textual contents of the node.
static void getNodeData(Node node, FastStringBuffer buf)
          Get the textual contents of the node.
 Node getParentOfNode(Node node)
          I have to write this silly, and expensive function, because the DOM WG decided that attributes don't have parents.
 Node getRoot(Node node)
          Deprecated.  
 Node getRootNode(Node n)
          Get the root node of the document tree, regardless of whether or not the node passed in is a document node.
 java.lang.String getUniqueID(Node node)
           
 java.lang.String getUnparsedEntityURI(java.lang.String name, Document doc)
          The getUnparsedEntityURI function returns the URI of the unparsed entity with the specified name in the same document as the context node (see [3.3 Unparsed Entities]).
 boolean isIgnorableWhitespace(Text node)
          Deprecated.  
 boolean isNamespaceNode(Node n)
          Tell if the given node is a namespace decl node.
 boolean isNodeAfter(Node node1, Node node2)
          Figure out if node2 should be placed after node1 in document order (returns node1 <= node2).
 void setDOMFactory(Document domFactory)
          Get the factory object required to create DOM nodes in the result tree.
 boolean shouldStripSourceNode(Node textNode)
          **For advanced use only** Tells, through the combination of the default-space attribute on xsl:stylesheet, xsl:strip-space, xsl:preserve-space, and the xml:space attribute, whether or not extra whitespace should be stripped from the node.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DOMHelper

public DOMHelper()
Method Detail

createDocument

public Document createDocument()
Used as a helper for handling DOM issues. May be subclassed to take advantage of specific DOM implementations.

shouldStripSourceNode

public boolean shouldStripSourceNode(Node textNode)
                              throws SAXException
**For advanced use only** Tells, through the combination of the default-space attribute on xsl:stylesheet, xsl:strip-space, xsl:preserve-space, and the xml:space attribute, whether or not extra whitespace should be stripped from the node. Literal elements from template elements should not be tested with this function.
Parameters:
textNode - A text node from the source tree.
Returns:
true if the text node should be stripped of extra whitespace.

getUniqueID

public java.lang.String getUniqueID(Node node)

isNodeAfter

public boolean isNodeAfter(Node node1,
                           Node node2)
Figure out if node2 should be placed after node1 in document order (returns node1 <= node2). NOTE: Make sure this does the right thing with attribute nodes!!!
Returns:
true if node2 should be placed after node1, and false if node2 should be placed before node1.

getLevel

public short getLevel(Node n)
**For internal use only** Get the depth level of this node in the tree (count from 1).

getNamespaceForPrefix

public java.lang.String getNamespaceForPrefix(java.lang.String prefix,
                                              Element namespaceContext)
Given a prefix and a namespace context, return the expanded namespace. Default handling:

getNamespaceOfNode

public java.lang.String getNamespaceOfNode(Node n)
Returns the namespace of the given node.

getLocalNameOfNode

public java.lang.String getLocalNameOfNode(Node n)
Returns the local name of the given node.

getExpandedElementName

public java.lang.String getExpandedElementName(Element elem)
Returns the element name with the namespace expanded.

getExpandedAttributeName

public java.lang.String getExpandedAttributeName(Attr attr)
Returns the attribute name with the namespace expanded.

isIgnorableWhitespace

public boolean isIgnorableWhitespace(Text node)
Deprecated.  
Tell if the node is ignorable whitespace.

getRoot

public Node getRoot(Node node)
Deprecated.  
Get the first unparented node in the ancestor chain.

getRootNode

public Node getRootNode(Node n)
Get the root node of the document tree, regardless of whether or not the node passed in is a document node.

isNamespaceNode

public boolean isNamespaceNode(Node n)
Tell if the given node is a namespace decl node.

getParentOfNode

public Node getParentOfNode(Node node)
                     throws java.lang.RuntimeException
I have to write this silly, and expensive function, because the DOM WG decided that attributes don't have parents. If Xalan is used with a DOM implementation that reuses attribute nodes, this will not work correctly.

getElementByID

public Element getElementByID(java.lang.String id,
                              Document doc)
Given an ID, return the element.

getUnparsedEntityURI

public java.lang.String getUnparsedEntityURI(java.lang.String name,
                                             Document doc)
The getUnparsedEntityURI function returns the URI of the unparsed entity with the specified name in the same document as the context node (see [3.3 Unparsed Entities]). It returns the empty string if there is no such entity. Since it states in the DOM draft: "An XML processor may choose to completely expand entities before the structure model is passed to the DOM; in this case, there will be no EntityReferences in the DOM tree." So I'm not sure how well this is going to work.

setDOMFactory

public void setDOMFactory(Document domFactory)
Get the factory object required to create DOM nodes in the result tree.

getDOMFactory

public Document getDOMFactory()
Get the factory object required to create DOM nodes in the result tree.

getNodeData

public static java.lang.String getNodeData(Node node)
Get the textual contents of the node. If the node is an element, apply whitespace stripping rules, though I'm not sure if this is right (I'll fix or declare victory when I review the entire whitespace handling).

getNodeData

public static void getNodeData(Node node,
                               FastStringBuffer buf)
Get the textual contents of the node. If the node is an element, apply whitespace stripping rules, though I'm not sure if this is right (I'll fix or declare victory when I review the entire whitespace handling).


Copyright © 2000 Apache XML Project. All Rights Reserved.