Search this API

y.io.graphml.input
Class XPathUtils

java.lang.Object
  extended by y.io.graphml.input.XPathUtils

public class XPathUtils
extends java.lang.Object

Static utility class that implements some commonly needed XML queries.

 

Method Summary
static java.util.Collection selectChildElements(org.w3c.dom.Node parent, java.lang.String localName, java.lang.String nsURI)
          Selects all child Elements of parent that have a matching Node name localName and XML namespace nsURI.
static org.w3c.dom.Node selectFirstChildElement(org.w3c.dom.Node parent, java.lang.String localName, java.lang.String nsURI)
          Selects the first child Element of parent that has a matching Node name localName and XML namespace nsURI.
static org.w3c.dom.Node selectFirstSignificantChild(org.w3c.dom.Node parent)
          Selects the first child Node of parent that represents significant content.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

selectFirstChildElement

public static org.w3c.dom.Node selectFirstChildElement(org.w3c.dom.Node parent,
                                                       java.lang.String localName,
                                                       java.lang.String nsURI)
Selects the first child Element of parent that has a matching Node name localName and XML namespace nsURI.

Using this query is not as efficient as true XPath queries, so you should use a real XPath processor if available.

Parameters:
parent - The parent node
localName - The local element name to match
nsURI - The XML namespace URI to match
Returns:
The first XML child element of parent matching the specifications, or null if no such element exists.

selectChildElements

public static java.util.Collection selectChildElements(org.w3c.dom.Node parent,
                                                       java.lang.String localName,
                                                       java.lang.String nsURI)
Selects all child Elements of parent that have a matching Node name localName and XML namespace nsURI.

Using this query is not as efficient as true XPath queries, so you should use a real XPath processor if available.

Parameters:
parent - The parent node
localName - The local element name to match
nsURI - The XML namespace URI to match
Returns:
A collection of all child elements of parent matching the specifications (if no such child exists, an empty collection is returned).

selectFirstSignificantChild

public static org.w3c.dom.Node selectFirstSignificantChild(org.w3c.dom.Node parent)
Selects the first child Node of parent that represents significant content.

This query returns the first child node that is neither:

Using this query is not as efficient as true XPath queries, so you should use a real XPath processor if available.

Parameters:
parent - The parent node
Returns:
The first child Node of parent that represents significant content. or null if no such child exists.

© Copyright 2000-2022,
yWorks GmbH.
All rights reserved.