org.ow2.util.xml
Class XMLUtils

java.lang.Object
  extended by org.ow2.util.xml.XMLUtils

public final class XMLUtils
extends java.lang.Object

Class with some useful methods on XML document.


Method Summary
static java.lang.String getAttributeValue(org.w3c.dom.Element base, java.lang.String name)
          Returns the value of the attribute of the given element.
static java.lang.String getChildStringValueForElement(org.w3c.dom.Element base, java.lang.String name)
          Returns the value of the child node with the given name.
static javax.xml.namespace.QName getChildValueAsQName(org.w3c.dom.Element base, java.lang.String name)
          Extract a node's child value as a QName.
[base element (declaring the prefix/namespace mapping)] #text-value: "prefix:local-part"
static java.util.Properties getPropertiesValueElement(java.lang.String ns, org.w3c.dom.Element base, java.lang.String name)
          Returns a Properties object matching the given node.
static java.util.List<java.lang.String> getStringListValueElement(org.w3c.dom.Element base, java.lang.String name)
          Returns a list of value for the given node.
static java.util.List<java.lang.String> getStringListValueElement(java.lang.String ns, org.w3c.dom.Element base, java.lang.String name)
          Returns a list of value for the given node.
static java.lang.String getStringValueElement(org.w3c.dom.Element base, java.lang.String name)
          Returns the value of the given node.
static java.lang.String getStringValueElement(org.w3c.dom.Element base, java.lang.String name, boolean trim)
          Returns the value of the given node.
static java.lang.String getStringValueElement(java.lang.String ns, org.w3c.dom.Element base, java.lang.String name)
          Returns the value of the given node or null if the node is not found.
static java.lang.String getStringValueElement(java.lang.String ns, org.w3c.dom.Element base, java.lang.String name, boolean trim)
          Returns the value of the given node or null if the node is not found.
static javax.xml.namespace.QName getValueAsQName(org.w3c.dom.Element base)
          Extract a node's value as a QName.
[base element (declaring the prefix/namespace mapping)] #text-value: "prefix:local-part"
static org.w3c.dom.Document newDocument(boolean namespaceAware)
          Creates a new empty Document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getStringValueElement

public static java.lang.String getStringValueElement(org.w3c.dom.Element base,
                                                     java.lang.String name)
Returns the value of the given node. (value trimed by default)

Parameters:
base - the element from where to search.
name - of the element to get.
Returns:
the value of this element.

getStringValueElement

public static java.lang.String getStringValueElement(org.w3c.dom.Element base,
                                                     java.lang.String name,
                                                     boolean trim)
Returns the value of the given node.

Parameters:
base - the element from where to search.
name - of the element to get.
trim - trim or not the value
Returns:
the value of this element.

getAttributeValue

public static java.lang.String getAttributeValue(org.w3c.dom.Element base,
                                                 java.lang.String name)
Returns the value of the attribute of the given element.

Parameters:
base - the element from where to search.
name - of the attribute to get.
Returns:
the value of this element.

getStringValueElement

public static java.lang.String getStringValueElement(java.lang.String ns,
                                                     org.w3c.dom.Element base,
                                                     java.lang.String name)
Returns the value of the given node or null if the node is not found.

Parameters:
ns - the namespace.
base - the element from where to search.
name - of the element to get.
Returns:
the value of this element or null if the element does not exists.

getStringValueElement

public static java.lang.String getStringValueElement(java.lang.String ns,
                                                     org.w3c.dom.Element base,
                                                     java.lang.String name,
                                                     boolean trim)
Returns the value of the given node or null if the node is not found.

Parameters:
ns - the namespace.
base - the element from where to search.
name - of the element to get.
trim - trim or not the returned value
Returns:
the value of this element or null if the element does not exists.

getChildStringValueForElement

public static java.lang.String getChildStringValueForElement(org.w3c.dom.Element base,
                                                             java.lang.String name)
Returns the value of the child node with the given name.

Parameters:
base - the element from where to search.
name - of the element to get.
Returns:
the value of this element.

getPropertiesValueElement

public static java.util.Properties getPropertiesValueElement(java.lang.String ns,
                                                             org.w3c.dom.Element base,
                                                             java.lang.String name)
Returns a Properties object matching the given node. Parse the following XML structure:
[base element] <ns:name> (only 1) <ns:property @name @value /> (0..n)

Parameters:
ns - the namespace.
base - the element from where to search.
name - of the element to get.
Returns:
the value of this element.

getStringListValueElement

public static java.util.List<java.lang.String> getStringListValueElement(java.lang.String ns,
                                                                         org.w3c.dom.Element base,
                                                                         java.lang.String name)
Returns a list of value for the given node.

Parameters:
ns - the namespace.
base - the element from where to search.
name - of the element to get.
Returns:
the list of value of this element.

getStringListValueElement

public static java.util.List<java.lang.String> getStringListValueElement(org.w3c.dom.Element base,
                                                                         java.lang.String name)
Returns a list of value for the given node.

Parameters:
base - the element from where to search.
name - of the element to get.
Returns:
the list of value of this element.

getChildValueAsQName

public static javax.xml.namespace.QName getChildValueAsQName(org.w3c.dom.Element base,
                                                             java.lang.String name)
Extract a node's child value as a QName.
[base element (declaring the prefix/namespace mapping)] #text-value: "prefix:local-part"

Parameters:
element - the element from where to search.
Returns:
The node's value as a QName.

getValueAsQName

public static javax.xml.namespace.QName getValueAsQName(org.w3c.dom.Element base)
Extract a node's value as a QName.
[base element (declaring the prefix/namespace mapping)] #text-value: "prefix:local-part"

Parameters:
base - the element from where to search.
Returns:
The node's value as a QName.

newDocument

public static org.w3c.dom.Document newDocument(boolean namespaceAware)
Creates a new empty Document.

Parameters:
namespaceAware - true if the created Document have to support namespaces.
Returns:
a new empty Document


Copyright © 2007-2009 OW2 Consortium. All Rights Reserved.