public class XmlBuilder
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private org.w3c.dom.Node |
baseNode
the base node
|
private org.w3c.dom.Node |
curNode
the current node, either the document node, document fragment node
or an element
|
private java.lang.String |
defaultPrefix
the default namespace prefix
|
private java.lang.String |
defaultURI
the default namespace URI
|
Constructor and Description |
---|
XmlBuilder(org.w3c.dom.Document doc)
constructor.
|
XmlBuilder(org.w3c.dom.DocumentFragment frag)
constructor.
|
XmlBuilder(org.w3c.dom.Node node)
constructor.
|
Modifier and Type | Method and Description |
---|---|
XmlBuilder |
attf(javax.xml.namespace.QName qName,
boolean value)
add an attribute to the current node, if it is an element node.
|
XmlBuilder |
attf(java.lang.String name,
boolean value)
add an attribute to the current node, if it is an element node.
|
XmlBuilder |
attf(java.lang.String uri,
java.lang.String qName,
boolean value)
add an attribute to the current node, if it is an element node.
|
XmlBuilder |
attf(java.lang.String uri,
java.lang.String prefix,
java.lang.String localName,
boolean value)
add an attribute to the current node, if it is an element node.
|
XmlBuilder |
attr(javax.xml.namespace.QName qName,
java.lang.Object value)
add an attribute to the current node, if it is an element node.
|
XmlBuilder |
attr(java.lang.String name,
java.lang.Object value)
add an attribute to the current node, if it is an element node.
|
XmlBuilder |
attr(java.lang.String uri,
java.lang.String qName,
java.lang.Object value)
add an attribute to the current node, if it is an element node.
|
XmlBuilder |
attr(java.lang.String uri,
java.lang.String prefix,
java.lang.String localName,
java.lang.Object value)
add an attribute to the current node, if it is an element node.
|
XmlBuilder |
clearNS()
clear the default namespace used for subsequent calls of the "simple"
element creation methods.
|
XmlBuilder |
comment(java.lang.String text)
add a comment node to the current node
|
XmlBuilder |
ee()
finish an element.
|
XmlBuilder |
elt(javax.xml.namespace.QName qName,
java.lang.Object value)
convenience method that adds an element with the given value as text.
|
XmlBuilder |
elt(java.lang.String name,
java.lang.Object value)
convenience method that adds an element with the given value as text.
|
XmlBuilder |
elt(java.lang.String uri,
java.lang.String qName,
java.lang.Object value)
convenience method that adds an element with the given value as text.
|
XmlBuilder |
elt(java.lang.String uri,
java.lang.String prefix,
java.lang.String localName,
java.lang.Object value)
convenience method that adds an element with the given value as text.
|
XmlBuilder |
es(javax.xml.namespace.QName qName)
create an element.
|
XmlBuilder |
es(java.lang.String localName)
create an element.
|
XmlBuilder |
es(java.lang.String uri,
java.lang.String qName)
create an element.
|
XmlBuilder |
es(java.lang.String uri,
java.lang.String prefix,
java.lang.String localName)
create an element.
|
org.w3c.dom.Node |
getBase()
return the base node
|
org.w3c.dom.Node |
getCurrent()
return the current node to which attributes, elements and texts are added
to.
|
XmlBuilder |
inc(XmlBuilder xb)
include the subtree created by the specified other instance.
|
XmlBuilder |
ns(java.lang.String uri)
set the default namespace used for subsequent calls of the "simple"
element creation methods.
|
XmlBuilder |
ns(java.lang.String uri,
java.lang.String prefix)
set the default namespace used for subsequent calls of the "simple"
element creation methods.
|
XmlBuilder |
t(java.lang.Object text)
add a text node to the current node.
|
XmlBuilder |
ttf(boolean value)
add a text node to the current node.
|
private org.w3c.dom.Node baseNode
private org.w3c.dom.Node curNode
private java.lang.String defaultURI
private java.lang.String defaultPrefix
public XmlBuilder(org.w3c.dom.Document doc) throws org.w3c.dom.DOMException
getBaseNode
.doc
- the documentorg.w3c.dom.DOMException
- if the creation of the fragment failedpublic XmlBuilder(org.w3c.dom.Node node)
node
- the nodepublic XmlBuilder(org.w3c.dom.DocumentFragment frag)
frag
- the fragmentpublic org.w3c.dom.Node getCurrent()
public org.w3c.dom.Node getBase()
public XmlBuilder ns(java.lang.String uri, java.lang.String prefix)
uri
- the URI; if null
, no namespace
is assigned to the subsequent elementsprefix
- the prefix, may be null
public XmlBuilder ns(java.lang.String uri)
uri
- the URI; if null
, no namespace
is assigned to the subsequent elementspublic XmlBuilder clearNS()
public XmlBuilder es(java.lang.String localName) throws org.w3c.dom.DOMException
localName
- the local part of the element nameorg.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder es(java.lang.String uri, java.lang.String qName) throws org.w3c.dom.DOMException
uri
- the name space URIqName
- the qualified name, i.e. a name with or
without a prefixorg.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder es(java.lang.String uri, java.lang.String prefix, java.lang.String localName) throws org.w3c.dom.DOMException
uri
- the name space URIprefix
- the prefix, may be null
or emptylocalName
- the local element nameorg.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder es(javax.xml.namespace.QName qName) throws org.w3c.dom.DOMException
qName
- the qualified name (as an object)org.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder ee()
public XmlBuilder attr(java.lang.String name, java.lang.Object value) throws org.w3c.dom.DOMException
null
the attribute is not added at all.
The mnemonic "attr" stands for "attribute".name
- the name of the attributevalue
- the valueorg.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder attf(java.lang.String name, boolean value) throws org.w3c.dom.DOMException
name
- the name of the attributevalue
- the valueorg.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder attr(java.lang.String uri, java.lang.String qName, java.lang.Object value) throws org.w3c.dom.DOMException
null
the attribute is not added at all.
The mnemonic "attr" stands for "attribute".uri
- the name space URIqName
- the qualified name, i.e. a name with orvalue
- the valueorg.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder attf(java.lang.String uri, java.lang.String qName, boolean value) throws org.w3c.dom.DOMException
uri
- the name space URIqName
- the qualified name, i.e. a name with or
without a prefixvalue
- the valueorg.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder attr(java.lang.String uri, java.lang.String prefix, java.lang.String localName, java.lang.Object value) throws org.w3c.dom.DOMException
null
the attribute is not added at all.
The mnemonic "attr" stands for "attribute".uri
- the name space URIprefix
- the prefix, may be null
or emptylocalName
- the local element namevalue
- the valueorg.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder attf(java.lang.String uri, java.lang.String prefix, java.lang.String localName, boolean value) throws org.w3c.dom.DOMException
uri
- the name space URIprefix
- the prefix, may be null
or emptylocalName
- the local element namevalue
- the valueorg.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder attr(javax.xml.namespace.QName qName, java.lang.Object value) throws org.w3c.dom.DOMException
null
the attribute is not added at all.
The mnemonic "attr" stands for "attribute".qName
- the qualified namevalue
- the valueorg.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder attf(javax.xml.namespace.QName qName, boolean value) throws org.w3c.dom.DOMException
qName
- the qualified namevalue
- the valueorg.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder t(java.lang.Object text) throws org.w3c.dom.DOMException
toString
. The mnemnonic "t" stands
for "text".text
- the text to add. If null
no node is createdorg.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder ttf(boolean value) throws org.w3c.dom.DOMException
value
- the valueorg.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder comment(java.lang.String text) throws org.w3c.dom.DOMException
text
- the textorg.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder elt(java.lang.String name, java.lang.Object value) throws org.w3c.dom.DOMException
null
, the element is not added at all.
The mnemonic "elt" stands for "element with text".name
- the name of the elementvalue
- the valueorg.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder elt(java.lang.String uri, java.lang.String qName, java.lang.Object value) throws org.w3c.dom.DOMException
null
, the element is not added at all.
The mnemonic "elt" stands for "element with text".uri
- the name space URIqName
- the qualified name, i.e. a name with or
without a prefixvalue
- the valueorg.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder elt(java.lang.String uri, java.lang.String prefix, java.lang.String localName, java.lang.Object value) throws org.w3c.dom.DOMException
null
, the element is not added at all.
The mnemonic "elt" stands for "element with text".uri
- the name space URIprefix
- the prefix, may be null
or emptylocalName
- the local element namevalue
- the valueorg.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder elt(javax.xml.namespace.QName qName, java.lang.Object value) throws org.w3c.dom.DOMException
null
, the element is not added at all.
The mnemonic "elt" stands for "element with text".qName
- the qualified namevalue
- the valueorg.w3c.dom.DOMException
- if the creation failedpublic XmlBuilder inc(XmlBuilder xb) throws org.w3c.dom.DOMException
xb
- the other builderorg.w3c.dom.DOMException
- if the creation failedCopyright © 2005-2013 Knipp Medien und Kommunikation GmbH