org.openspml.v2.util.xml
Class XmlElement

java.lang.Object
  extended byorg.openspml.v2.util.xml.XmlElement

public class XmlElement
extends java.lang.Object

A wrapper around the standard DOM Element that provides a more convenient set of methods.


Field Summary
static java.lang.String code_id
           
 
Constructor Summary
XmlElement(org.w3c.dom.Element e)
           
 
Method Summary
 java.lang.String getAttribute(java.lang.String name)
          Return the value of an attribute.
 boolean getBooleanAttribute(java.lang.String name)
          Return a boolean attribute value.
 XmlElement getChildElement()
          Return the first child element.
 XmlElement getChildElement(java.lang.String localName)
          Return the first child element with the given local name.
 java.lang.String getContent()
          Return the content of the given element.
 java.lang.String getLocalName()
          Return the element tag name without the namespace qualifier.
 java.lang.String getNamespaceURI()
          Given an element with a namespace prefix and a namespace declaration for that prefix, return the namespace URI.
 XmlElement getNextElement()
          Get the next right sibling that is an element.
 java.lang.String getPrefix()
          Return the namespace prefix.
 java.lang.String getTagName()
           
 XmlElement next()
          Assimilate the next right sibling within this element wrapper.
static java.lang.String stripPrefix(java.lang.String value)
          Remove an identifier prefix from an attribute value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

code_id

public static final java.lang.String code_id
See Also:
Constant Field Values
Constructor Detail

XmlElement

public XmlElement(org.w3c.dom.Element e)
Method Detail

getTagName

public java.lang.String getTagName()

getLocalName

public java.lang.String getLocalName()
Return the element tag name without the namespace qualifier.


getPrefix

public java.lang.String getPrefix()
Return the namespace prefix.


getNamespaceURI

public java.lang.String getNamespaceURI()
Given an element with a namespace prefix and a namespace declaration for that prefix, return the namespace URI. Note that this is not as general as the DOM method, the only scope examined is the local element.


stripPrefix

public static java.lang.String stripPrefix(java.lang.String value)
Remove an identifier prefix from an attribute value.


getAttribute

public java.lang.String getAttribute(java.lang.String name)
Return the value of an attribute.

The DOM getAttribute method returns an empty string if the attribute doesn't exist. Here, we detect this and return null.


getBooleanAttribute

public boolean getBooleanAttribute(java.lang.String name)
Return a boolean attribute value.

The value must be equal to the string "true" or "1" to be considered true.


getChildElement

public XmlElement getChildElement()
Return the first child element.


getChildElement

public XmlElement getChildElement(java.lang.String localName)
Return the first child element with the given local name. Used during SPML parsing to skip over the optional SOAP header and get to the Body.


getNextElement

public XmlElement getNextElement()
Get the next right sibling that is an element.


next

public XmlElement next()
Assimilate the next right sibling within this element wrapper. This makes the element behave more like an iterator which is usually what you want and cuts down on garbage.


getContent

public java.lang.String getContent()
Return the content of the given element.

We will descend to an arbitrary depth looking for the first non-empty text node.

Note that the parser may break what was originally a single string of pcdata into multiple adjacent text nodes. Xerces appears to do this when it encounters a '$' in the text, not sure if there is specified behavior, or if its parser specific.

Here, we will congeal adjacent text nodes.

We will NOT ignore text nodes that have only whitespace.



Copyright © Sun Microsystems, Inc. All Rights Reserved.