sk.uniba.euromath.tools.xml
Class DomTools

java.lang.Object
  extended by sk.uniba.euromath.tools.xml.DomTools

Deprecated. moved to the sk.baka.ikslibs package

@Deprecated
public final class DomTools
extends Object

DomTools for document package.

Author:
Martin Vysny

Constructor Summary
DomTools()
          Deprecated.  
 
Method Summary
static void clearAttributes(Node node)
          Deprecated. Removes all attribute nodes (including xmlns: attributes) from given node.
static void clearChildren(Node node, boolean checkUndeletable)
          Deprecated. Deletes all child nodes in the node (all nodes from the document, for example).
static boolean containsElements(Node node)
          Deprecated. Checks, whether given node contains some elements also, or it contains text/comments/pi only.
static boolean equalsNodeNamespace(Node node1, Node node2)
          Deprecated. Returns true if the two Nodes are from same namespace.
static boolean equalsNodeQName(Node node1, Node node2)
          Deprecated. Returns true if the two Nodes have same qname (namespace and localname).
static boolean equalsNodeQName(Node node, QName name)
          Deprecated. Returns true if the node is from given namespace and has name localName.
static boolean equalsNodeQName(Node node, String namespaceURI, String localName)
          Deprecated. Returns true if the node is from provided namespace and has name localName.
static boolean equalsQName(QName qname, String namespace, String localName)
          Deprecated. Returns true if given qname represents given namespace and local name.
static boolean equalsURI(String uri1, String uri2)
          Deprecated. Returns true if the two uri are equal.
static void getAttributes(Node n, List<Attr> list, boolean descendants)
          Deprecated. Appends all attribute nodes from given element to given list.
static List<Element> getChildElements(Node node)
          Deprecated. Returns all elements, that are children of given node.
static String getErrorMessage(DOMError err)
          Deprecated. Distills the detailed error message from the error object.
static Element getFirstChildElement(Node node)
          Deprecated. Returns first element contained in the node.
static Node getFirstDescendantOrSelfIdentifiableNode(Node node)
          Deprecated. Returns first identifiable node encountered on descendant-or-self axis of given node.
static CharacterData getFirstDescendantOrSelfTextualNode(Node node)
          Deprecated. Returns first textual node encountered on descendant-or-self axis of given node.
static Node getLastDescendantOrSelfIdentifiableNode(Node node)
          Deprecated. Returns last identifiable node encountered on descendant-or-self axis of given node.
static CharacterData getLastDescendantOrSelfTextualNode(Node node)
          Deprecated. Returns last textual node encountered.
static String getMarkElementId(Element e)
          Deprecated. Retrieves ID from the emp:mark element.
static Node getNearestCommonAscendant(Node node1, Node node2)
          Deprecated. Computes and returns common ascendant for both nodes.
static int getNodeIndex(Node node)
          Deprecated. Returns zero-based index of node (i.e.
static List<Node> getNodePathToRoot(Node node)
          Deprecated. Returns path from given node to the root node.
static Node getParentContainer(Node node)
          Deprecated. Returns the parent container of the node.
static Element getParentElement(Node node)
          Deprecated. Returns the parent element of the node.
static String getPathToRoot(Node node)
          Deprecated. Returns human-readable path from given element to root of document, in a form /root/.../element.
static QName getQName(Node node)
          Deprecated. Returns QName object containing qualified name of given node.
static QName getQName(String uri, String localName, String qName)
          Deprecated. Converts SAX-style qname to the QName instance.
static Element getRootElement(DOMSource source)
          Deprecated. Returns root element of given source.
static String getTextContents(Node node, org.w3c.dom.traversal.NodeFilter filter)
          Deprecated. Retrieves textual value of the node: all nodes except element, text, cdata and entity are ignored.
static boolean hasEmptyContent(Node node)
          Deprecated. Checks if node has empty content: empty text nodes, empty entities, entities that contains empty text nodes or empty entities etc.
static boolean inEntity(Node node)
          Deprecated. Queries if the given node is a descendant of an EntityReference node.
static boolean isContainer(Node node)
          Deprecated. Checks if given node is able to contain other nodes as its children.
static boolean isContentNode(Node node)
          Deprecated. Returns true if the node is a content node: if it can be a part of DOM document content.
static boolean isDocumentRoot(Node node)
          Deprecated. Checks if the node is a root node.
static boolean isEmptyEntity(Node node)
          Deprecated. Check if given node is an empty entity.
static boolean isEntity(Node node)
          Deprecated. Checks if given node is entity or entity reference node.
static boolean isPartiallySelectable(Node node)
          Deprecated. Checks if the node is partially selectable.
static boolean isPartiallySelectable(short nodeType)
          Deprecated. Checks if the node is partially selectable.
static boolean isRootNode(Node node)
          Deprecated. Checks if this node is a root node in the node hierarchy.
static boolean isText(Node node)
          Deprecated. Checks if the node is a textual node - text or cdata node.
static boolean isText(short nodeType)
          Deprecated. Checks if the node is a textual node - text or cdata node.
static boolean isTextualEntity(Node node)
          Deprecated. Checks if given node is an entity reference that contains text/cdata nodes only.
static boolean isTextualNode(Node node)
          Deprecated. Returns true if the node represents text only - itself is textual or it is a pure-textual entity.
static DocumentFragment moveContentToFragment(Document doc)
          Deprecated. Moves all content nodes from the document into newly created document fragment.
static List<Node> nodeListToList(NodeList nodeList)
          Deprecated. Converts nodeList to List.
static String printQName(Node node)
          Deprecated. Prints given node qname as a prefix:localname pair.
static String printQName(QName qname)
          Deprecated. Prints given qname as a prefix:localname pair.
static String printQName(String prefix, String local)
          Deprecated. Prints given qname as a prefix:localname pair.
static void removeXmlns(Element e)
          Deprecated. Removes all xmlns attributes from given element.
static void setReadOnly(Node node, boolean readOnly, boolean deep)
          Deprecated.  Description copied from Xerces 2.7.1 NodeImpl.setReadOnly(boolean, boolean) method.
static DocumentFragment toFragment(Node node)
          Deprecated. Converts the node into a document fragment.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DomTools

public DomTools()
Deprecated. 
Method Detail

equalsURI

public static boolean equalsURI(String uri1,
                                String uri2)
Deprecated. 
Returns true if the two uri are equal. "" and null are equal.

Parameters:
uri1 - first uri
uri2 - second uri
Returns:
uri1 == null ? uri2 == null : uri1.equals(uri2)

equalsNodeQName

public static boolean equalsNodeQName(Node node,
                                      String namespaceURI,
                                      String localName)
Deprecated. 
Returns true if the node is from provided namespace and has name localName.

Parameters:
node - Node to check.
namespaceURI - namespace that the node must be from.
localName - name that must node have.
Returns:
true if name of node is namespaceURI:localName

equalsNodeQName

public static boolean equalsNodeQName(Node node,
                                      QName name)
Deprecated. 
Returns true if the node is from given namespace and has name localName.

Parameters:
node - Node to check.
name - qualified name.
Returns:
true if name of node is from namespaceURI:localName

equalsNodeNamespace

public static boolean equalsNodeNamespace(Node node1,
                                          Node node2)
Deprecated. 
Returns true if the two Nodes are from same namespace.

Parameters:
node1 - First Node to compare.
node2 - Second Node to compare.
Returns:
true if the two Nodes are from same namespace.

equalsNodeQName

public static boolean equalsNodeQName(Node node1,
                                      Node node2)
Deprecated. 
Returns true if the two Nodes have same qname (namespace and localname).

Parameters:
node1 - First Node to compare.
node2 - Second Node to compare.
Returns:
true if the two Nodes are from same namespace and have same localname.

equalsQName

public static boolean equalsQName(QName qname,
                                  String namespace,
                                  String localName)
Deprecated. 
Returns true if given qname represents given namespace and local name.

Parameters:
qname - qualified name.
namespace - the namespace to check.
localName - local name to check.
Returns:
true if both namespace and localname are equal, false otherwise.

getNodeIndex

public static int getNodeIndex(Node node)
Deprecated. 
Returns zero-based index of node (i.e. how many nodes are its previous siblings).

Parameters:
node - the node to test.
Returns:
node index, or -1 if null was given.

clearChildren

public static void clearChildren(Node node,
                                 boolean checkUndeletable)
Deprecated. 
Deletes all child nodes in the node (all nodes from the document, for example). Does nothing for non-container nodes like text, cdata, pi, comment, attribute.

Parameters:
node - the node.
checkUndeletable - if true then function will fail if undeletable element occurs.
Throws:
IllegalArgumentException - if node is entity, entity reference or notation node.

getChildElements

public static List<Element> getChildElements(Node node)
Deprecated. 
Returns all elements, that are children of given node. The ordering is preserved.

Parameters:
node - the node to process
Returns:
modifiable ordered list of elements, never null.

isText

public static boolean isText(Node node)
Deprecated. 
Checks if the node is a textual node - text or cdata node.

Parameters:
node - the node to check.
Returns:
true if node is Text or CDATASection node, false otherwise.

isText

public static boolean isText(short nodeType)
Deprecated. 
Checks if the node is a textual node - text or cdata node.

Parameters:
nodeType - the node type to check.
Returns:
true if node is Text or CDATASection node, false otherwise.

isPartiallySelectable

public static boolean isPartiallySelectable(Node node)
Deprecated. 
Checks if the node is partially selectable. Only text, cdata and comment nodes are partially selectable.

Parameters:
node - node to check.
Returns:
true if node is Text, CDATASection or Comment, false otherwise.

isPartiallySelectable

public static boolean isPartiallySelectable(short nodeType)
Deprecated. 
Checks if the node is partially selectable. Only text, cdata and comment nodes are partially selectable.

Parameters:
nodeType - the node type to check.
Returns:
true if node is Text, CDATASection or Comment, false otherwise.

inEntity

public static boolean inEntity(Node node)
Deprecated. 
Queries if the given node is a descendant of an EntityReference node.

Parameters:
node - node to check.
Returns:
true if node is descendant of EntityReference node. In case of attribute the function checks if its owner element is in entity. If the node itself is EntityReference node but is not contained in other entity reference node then the result is false.

getParentElement

public static Element getParentElement(Node node)
Deprecated. 
Returns the parent element of the node. It may differ from node.getParentNode() when the node is in an entity reference node.

Parameters:
node - the node to check.
Returns:
the parent element. It may be null if and only if given node is the root node of some document, document or document fragment.
Throws:
IllegalArgumentException - if the node does not have a parent.

getParentContainer

public static Node getParentContainer(Node node)
Deprecated. 
Returns the parent container of the node. It may differ from node.getParentNode() when the node is in an entity reference node. A container is an ID-level node holder; it is never an entity reference, for example. It is equal to getParentElement if it is not null. If getParentElement is null then this container is a Document or document fragment instance.

Parameters:
node - the node to check.
Returns:
the parent container. It may be null if and only if given node is disconnected from any element, document or document fragment node.
Throws:
IllegalArgumentException - if the node does not have a parent.

containsElements

public static boolean containsElements(Node node)
Deprecated. 
Checks, whether given node contains some elements also, or it contains text/comments/pi only. It checks also contents of entity reference nodes, contained in given node.

Parameters:
node - the node.
Returns:
true if node contains at least one regular element, false otherwise.

isTextualEntity

public static boolean isTextualEntity(Node node)
Deprecated. 
Checks if given node is an entity reference that contains text/cdata nodes only. Empty entity is textual.

Parameters:
node - node to check.
Returns:
true if it is an entity that contains text/cdata nodes or textual entities only, false if the node is not an entity or it contains comments/pi/elements.

hasEmptyContent

public static boolean hasEmptyContent(Node node)
Deprecated. 
Checks if node has empty content: empty text nodes, empty entities, entities that contains empty text nodes or empty entities etc.

Parameters:
node - the nodes to check
Returns:
true if the content of the node does not contain any element, character, comment etc.

isEmptyEntity

public static boolean isEmptyEntity(Node node)
Deprecated. 
Check if given node is an empty entity.

Parameters:
node - node to check.
Returns:
true if the node is an empty entity and it has empty content.

isEntity

public static boolean isEntity(Node node)
Deprecated. 
Checks if given node is entity or entity reference node.

Parameters:
node - the node to check.
Returns:
true if node is entity or entity reference node, false otherwise.

isTextualNode

public static boolean isTextualNode(Node node)
Deprecated. 
Returns true if the node represents text only - itself is textual or it is a pure-textual entity.

Parameters:
node - node to check
Returns:
true if it is textual or textual entity.

getFirstDescendantOrSelfTextualNode

public static CharacterData getFirstDescendantOrSelfTextualNode(Node node)
Deprecated. 
Returns first textual node encountered on descendant-or-self axis of given node. It may return given node itself. Checks all descendants of given node.

Parameters:
node - the node to check.
Returns:
first descendant-or-self of node in the document order. If node itself is textual then it is returned.

getFirstDescendantOrSelfIdentifiableNode

public static Node getFirstDescendantOrSelfIdentifiableNode(Node node)
Deprecated. 
Returns first identifiable node encountered on descendant-or-self axis of given node. It may return given node itself. Checks all descendants of given node.

Parameters:
node - the node to check.
Returns:
first descendant-or-self of node in the document order. If node itself is identifiable then it is returned.

getLastDescendantOrSelfIdentifiableNode

public static Node getLastDescendantOrSelfIdentifiableNode(Node node)
Deprecated. 
Returns last identifiable node encountered on descendant-or-self axis of given node. It may return given node itself but this option is examined as a last option. Checks all descendants of given node first.

Parameters:
node - the node to check.
Returns:
last descendant-or-self of node in the document order. If no suitable text node is found then return null.

getLastDescendantOrSelfTextualNode

public static CharacterData getLastDescendantOrSelfTextualNode(Node node)
Deprecated. 
Returns last textual node encountered. It may return given node itself, but this option is examined as a last option. Checks all descendants of given node.

Parameters:
node - the node to check.
Returns:
last descendant-or-self of node in the document order. If no suitable text node is found then return null.

isDocumentRoot

public static boolean isDocumentRoot(Node node)
Deprecated. 
Checks if the node is a root node. Root node is a node that has null parent or its parent is document or document fragment.

Parameters:
node - the node to check.
Returns:
true if the node is a root node of some document.

isContainer

public static boolean isContainer(Node node)
Deprecated. 
Checks if given node is able to contain other nodes as its children.

Parameters:
node - node to check
Returns:
true if node is element, entity, entity reference, document or document fragment node.

printQName

public static String printQName(String prefix,
                                String local)
Deprecated. 
Prints given qname as a prefix:localname pair.

Parameters:
local - the local part of the qname.
prefix - the prefix of the qname.
Returns:
name formatted in the prefix:localname format.

printQName

public static String printQName(Node node)
Deprecated. 
Prints given node qname as a prefix:localname pair.

Parameters:
node - the node
Returns:
name formatted in the prefix:localname format.

printQName

public static String printQName(QName qname)
Deprecated. 
Prints given qname as a prefix:localname pair.

Parameters:
qname - the qname
Returns:
name formatted in the prefix:localname format.

getQName

public static QName getQName(Node node)
Deprecated. 
Returns QName object containing qualified name of given node.

Parameters:
node - node to convert. Must be element or attribute node.
Returns:
QName of the node.

getQName

public static QName getQName(String uri,
                             String localName,
                             String qName)
Deprecated. 
Converts SAX-style qname to the QName instance.

Parameters:
uri - the Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed
localName - the local name (without prefix), or the empty string if Namespace processing is not being performed
qName - the qualified XML name (with prefix), or the empty string if qualified names are not available
Returns:
qname instance.

isContentNode

public static boolean isContentNode(Node node)
Deprecated. 
Returns true if the node is a content node: if it can be a part of DOM document content.

Parameters:
node - node to check.
Returns:
true if the node is an attribute, element, text, cdata, pi, comment or entity reference node.

moveContentToFragment

public static DocumentFragment moveContentToFragment(Document doc)
Deprecated. 
Moves all content nodes from the document into newly created document fragment.

Parameters:
doc - the document node.
Returns:
fragment containing all content children of given document.

toFragment

public static DocumentFragment toFragment(Node node)
Deprecated. 
Converts the node into a document fragment. If node is a document fragment then it is simply returned. If node is a document then all nodes are moved using the moveContentToFragment method. If node is content node then it shall be the sole child of the returned fragment.

Parameters:
node - node to convert.
Returns:
document fragment representing given node.
Throws:
IllegalArgumentException - if node is not fragment, document nor content node.

getFirstChildElement

public static Element getFirstChildElement(Node node)
Deprecated. 
Returns first element contained in the node. If the node is a Document instance then returns document's element.

Parameters:
node - node to scan
Returns:
element contained in the node, or null if no such element exists.

clearAttributes

public static void clearAttributes(Node node)
Deprecated. 
Removes all attribute nodes (including xmlns: attributes) from given node.

Parameters:
node - remove attributes from this node. Only element can have attributes hence function does nothing for other types of nodes.
Throws:
UnremovableAttributeException - if some attributes are not removable.

removeXmlns

public static void removeXmlns(Element e)
Deprecated. 
Removes all xmlns attributes from given element.

Parameters:
e - element to modify.
Throws:
UnremovableAttributeException - if an unremovable xmlns attribute occured.

getPathToRoot

public static String getPathToRoot(Node node)
Deprecated. 
Returns human-readable path from given element to root of document, in a form /root/.../element. Only local names are displayed, no namespaces. Useful for printing element location.

Parameters:
node - display path for this node (element or entity reference).
Returns:
path of element localnames.

getRootElement

public static Element getRootElement(DOMSource source)
Deprecated. 
Returns root element of given source.

Parameters:
source - the source to analyze.
Returns:
root element, or null if no element node is attached to source's node.

getMarkElementId

public static String getMarkElementId(Element e)
Deprecated. 
Retrieves ID from the emp:mark element. If the node is not an emp:mark element, the function fails.

Parameters:
e - the emp:mark element instance.
Returns:
ID marking root element of nametree where the emp:mark points. Never null.

nodeListToList

public static List<Node> nodeListToList(NodeList nodeList)
Deprecated. 
Converts nodeList to List.

Parameters:
nodeList - the node list.
Returns:
list of nodes.

getErrorMessage

public static String getErrorMessage(DOMError err)
Deprecated. 
Distills the detailed error message from the error object.

Parameters:
err - error to analyze.
Returns:
detailed error message.

setReadOnly

public static void setReadOnly(Node node,
                               boolean readOnly,
                               boolean deep)
Deprecated. 

Description copied from Xerces 2.7.1 NodeImpl.setReadOnly(boolean, boolean) method.

NON-DOM: PR-DOM-Level-1-19980818 mentions readonly nodes in conjunction with Entities, but provides no API to support this.

Most DOM users should not touch this method. Its anticpated use is during construction of EntityRefernces, where it will be used to lock the contents replicated from Entity so they can't be casually altered. It _could_ be published as a DOM extension, if desired.

Parameters:
node - the node to modify
readOnly - true or false as desired.
deep - If true, children are also toggled. Note that this will not change the state of an EntityReference or its children, which are always read-only.

getTextContents

public static String getTextContents(Node node,
                                     org.w3c.dom.traversal.NodeFilter filter)
Deprecated. 
Retrieves textual value of the node: all nodes except element, text, cdata and entity are ignored.

Parameters:
node - node to retrieve textual value from. If attribute is specified then its value is returned.
filter - filters out nodes. If null then no nodes are filtered. The function differentiates NodeFilter.FILTER_SKIP and NodeFilter.FILTER_REJECT.
Returns:
textual value of given node.

getAttributes

public static void getAttributes(Node n,
                                 List<Attr> list,
                                 boolean descendants)
Deprecated. 
Appends all attribute nodes from given element to given list.

Parameters:
n - append attributes from this element. emp:id attribute is ignored.
list - attributes are appended to this list, in no specified order.
descendants - if true then all descendant elements are considered.

getNodePathToRoot

public static List<Node> getNodePathToRoot(Node node)
Deprecated. 
Returns path from given node to the root node.

Parameters:
node - display path for this node.
Returns:
path of element localnames. First item (index 0) is given node, last item is a root item - its parent is null.

getNearestCommonAscendant

public static Node getNearestCommonAscendant(Node node1,
                                             Node node2)
Deprecated. 
Computes and returns common ascendant for both nodes.

Parameters:
node1 - first node
node2 - second node.
Returns:
a node that ascends both node1 and node2, and is nearest such node to node1 and node2. If nodes are disconnected, returns null.

isRootNode

public static boolean isRootNode(Node node)
Deprecated. 
Checks if this node is a root node in the node hierarchy.

Parameters:
node - the node to check.
Returns:
true if the parent of the node is null or is the node itself.


Copyright 2003-2003-2006 null. All Rights Reserved.