|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.lenya.xml.NamespaceHelper
public class NamespaceHelper
A NamespaceHelper object simplifies the creation of elements in a certain
namespace. All elements are owned by a document that is passed to the
NamespaceHelper(String, String, Document)
constructor or created
using the NamespaceHelper(String, String, String)
constructor.
Constructor Summary | |
---|---|
NamespaceHelper(java.lang.String _namespaceUri,
java.lang.String _prefix,
org.w3c.dom.Document _document)
Creates a new instance of NamespaceHelper using an existing document. |
|
NamespaceHelper(java.lang.String _namespaceUri,
java.lang.String _prefix,
java.lang.String localName)
Creates a new instance of NamespaceHelper. |
Method Summary | |
---|---|
org.w3c.dom.Element |
createElement(java.lang.String localName)
Creates an element within the namespace of this NamespaceHelper object with a given local name containing a text node. |
org.w3c.dom.Element |
createElement(java.lang.String localName,
java.lang.String text)
Creates an element within the namespace of this NamespaceHelper object with a given local name containing a text node. |
org.w3c.dom.Element[] |
getChildren(org.w3c.dom.Element element)
Returns all children of an element in the namespace of this NamespaceHelper. |
org.w3c.dom.Element[] |
getChildren(org.w3c.dom.Element element,
java.lang.String localName)
Returns all children of an element with a local name in the namespace of this NamespaceHelper. |
org.w3c.dom.Document |
getDocument()
Returns the document that is used to create elements. |
org.w3c.dom.Element |
getFirstChild(org.w3c.dom.Element element,
java.lang.String localName)
Returns the first childr of an element with a local name in the namespace of this NamespaceHelper or null if none exists. |
java.lang.String |
getNamespaceURI()
Returns the namespace URI of this NamespaceHelper. |
org.w3c.dom.Element[] |
getNextSiblings(org.w3c.dom.Element element,
java.lang.String localName)
Returns the next siblings of an element with a local name in the namespace of this NamespaceHelper or null if none exists. |
org.w3c.dom.Element[] |
getPrecedingSiblings(org.w3c.dom.Element element,
java.lang.String localName)
Returns the preceding siblings of an element with a local name in the namespace of this NamespaceHelper or null if none exists. |
java.lang.String |
getPrefix()
Returns the namespace prefix that is used to create elements. |
static java.lang.String |
getQualifiedName(java.lang.String prefix,
java.lang.String localName)
Returns the qualified name for a local name using the prefix of this NamespaceHelper. |
void |
save(java.io.OutputStream stream)
Saves the XML. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public NamespaceHelper(java.lang.String _namespaceUri, java.lang.String _prefix, org.w3c.dom.Document _document)
null
, the default namespace
is used.
_document
- The document._namespaceUri
- The namespace URI._prefix
- The namespace prefix.public NamespaceHelper(java.lang.String _namespaceUri, java.lang.String _prefix, java.lang.String localName) throws javax.xml.parsers.ParserConfigurationException
Creates a new instance of NamespaceHelper. A new document is created using a document element in the given namespace with the given prefix. If the prefix is null, the default namespace is used.
NamespaceHelper("http://www.w3.org/2000/svg", "svg", "svg"):
<?xml version="1.0">
<svg:svg
xmlns:svg="http://www.w3.org/2000/svg">
</svg:svg>
localName
- The local name of the document element._namespaceUri
- The namespace URI._prefix
- The namespace prefix.
javax.xml.parsers.ParserConfigurationException
- if an error occuredMethod Detail |
---|
public org.w3c.dom.Document getDocument()
public java.lang.String getNamespaceURI()
public java.lang.String getPrefix()
public static java.lang.String getQualifiedName(java.lang.String prefix, java.lang.String localName)
prefix
- The namespace prefix.localName
- The local name.
public org.w3c.dom.Element createElement(java.lang.String localName)
Creates an element within the namespace of this NamespaceHelper object
with a given local name containing a text node.
createElement("text")
: <prefix:text/>
.
localName
- The local name of the element.
public org.w3c.dom.Element createElement(java.lang.String localName, java.lang.String text)
Creates an element within the namespace of this NamespaceHelper object with a given local name containing a text node.
createElement("text", "Hello World!")
:
<prefix:text>Hello World!</prefix:text>
.
localName
- The local name of the element.text
- The text for the text node inside the element.
public org.w3c.dom.Element[] getChildren(org.w3c.dom.Element element)
element
- The parent element.
public org.w3c.dom.Element[] getChildren(org.w3c.dom.Element element, java.lang.String localName)
element
- The parent element.localName
- The local name of the children to return.
public org.w3c.dom.Element getFirstChild(org.w3c.dom.Element element, java.lang.String localName)
null
if none exists.
element
- The parent element.localName
- The local name of the children to return.
public org.w3c.dom.Element[] getNextSiblings(org.w3c.dom.Element element, java.lang.String localName)
null
if none exists.
element
- The parent element.localName
- The local name of the children to return.
public org.w3c.dom.Element[] getPrecedingSiblings(org.w3c.dom.Element element, java.lang.String localName)
null
if none exists.
element
- The parent element.localName
- The local name of the children to return.
public void save(java.io.OutputStream stream)
stream
- The stream to write to.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |