|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.mycila.xmltool.XMLDoc
public final class XMLDoc
Method Summary | |
---|---|
XMLTag |
addAttribute(org.w3c.dom.Attr attr)
Add given attribute to current element |
XMLTag |
addAttribute(java.lang.String name,
java.lang.String value)
Create a new attribute for the current node |
XMLTag |
addCDATA(org.w3c.dom.CDATASection data)
Add a CDATA note to the current tag |
XMLTag |
addCDATA(java.lang.String data)
Add a data node under the current node, and jump to the parent node. |
XMLTag |
addDocument(org.w3c.dom.Document doc)
Inserts another Document instance under the current tag |
XMLTag |
addDocument(XMLTag tag)
Inserts another XMLTag instance under the current tag. |
XMLTag |
addNamespace(java.lang.String prefix,
java.lang.String namespaceURI)
Add a namespace to the document |
XMLTag |
addTag(org.w3c.dom.Element tag)
Inserts a Element instance and its hierarchy under the current tag |
XMLTag |
addTag(java.lang.String name)
Create a tag under the current location and use it as the current node |
XMLTag |
addTag(XMLTag tag)
Inserts another XMLTag tag hierarchy under the current tag. |
XMLTag |
addText(java.lang.String text)
Add a text node under the current node, and jump to the parent node. |
XMLTag |
addText(org.w3c.dom.Text text)
Add a text note to the current tag |
XMLTag |
delete()
Delete current tag and its childs. |
XMLTag |
deleteAttribute(java.lang.String name)
Delete an attribute of the current node. |
XMLTag |
deleteAttributeIfExists(java.lang.String name)
Delete an attribute of the current node, if it exists |
XMLTag |
deleteAttributes()
Delete all existing attributes of current node |
XMLTag |
deleteChilds()
Delete all existing elements of this node |
XMLTag |
deletePrefixes()
Remove any prefix and namespaces contained in the tag name, childs and attributes, thus changing namespace and tag name. |
XMLTag |
duplicate()
|
java.lang.String |
findAttribute(java.lang.String name)
returns the attribute value of the current node or null if the attribute does not exist |
java.lang.String |
findAttribute(java.lang.String name,
java.lang.String relativeXpath,
java.lang.Object... arguments)
Returns the attribute value of the node pointed by given XPath expression or null if the attribute does not exist |
XMLTag |
forEach(CallBack callBack,
java.lang.String relativeXpath,
java.lang.Object... arguments)
Execute an action for each selected tags from the current node. |
XMLTag |
forEach(java.lang.String xpath,
CallBack callBack)
|
XMLTag |
forEachChild(CallBack callBack)
Execute an action for each child in the current node. |
static XMLTag |
from(java.io.File file,
boolean ignoreNamespaces)
|
static XMLTag |
from(org.xml.sax.InputSource source,
boolean ignoreNamespaces)
|
static XMLTag |
from(java.io.InputStream is,
boolean ignoreNamespaces)
|
static XMLTag |
from(org.w3c.dom.Node node,
boolean ignoreNamespaces)
|
static XMLTag |
from(java.io.Reader reader,
boolean ignoreNamespaces)
|
static XMLTag |
from(javax.xml.transform.Source source,
boolean ignoreNamespaces)
|
static XMLTag |
from(java.lang.String xmlData,
boolean ignoreNamespaces)
|
static XMLTag |
from(java.net.URL xmlLocation,
boolean ignoreNamespaces)
|
static XMLTag |
from(XMLTag tag,
boolean ignoreNamespaces)
|
static XMLTag |
fromCurrentTag(XMLTag tag,
boolean ignoreNamespaces)
Create another XMLTag instance from the hierarchy under the current tag. |
java.lang.String |
getAttribute(java.lang.String name)
returns the attribute value of the current node |
java.lang.String |
getAttribute(java.lang.String name,
java.lang.String relativeXpath,
java.lang.Object... arguments)
Returns the attribute value of the node pointed by given XPath expression |
java.lang.String[] |
getAttributeNames()
|
java.lang.String |
getCDATA()
|
java.lang.String |
getCDATA(java.lang.String relativeXpath,
java.lang.Object... arguments)
Get the CDATA of a selected node |
java.lang.String |
getCDATAorText()
|
java.lang.String |
getCDATAorText(java.lang.String relativeXpath,
java.lang.Object... arguments)
Get the text of a sepcific node |
int |
getChildCount()
|
java.util.List<org.w3c.dom.Element> |
getChildElement()
|
java.lang.Iterable<XMLTag> |
getChilds()
XMLTag tag = XMLDoc.newDocument(true)
.addRoot("root").addTag("a")
.gotoParent().addTag("b")
.gotoParent().addTag("c")
.gotoRoot();
assertEquals(tag.getCurrentTagName(), "root");
for (XMLTag xmlTag : tag.getChilds()) {
if(xmlTag.getCurrentTagName().equals("b")) {
break;
}
}
assertEquals(tag.getCurrentTagName(), "b"); |
java.lang.Iterable<XMLTag> |
getChilds(java.lang.String relativeXpath,
java.lang.Object... arguments)
Create an iterable object over selected elements. |
javax.xml.namespace.NamespaceContext |
getContext()
|
org.w3c.dom.Element |
getCurrentTag()
|
java.lang.String |
getCurrentTagLocation()
|
java.lang.String |
getCurrentTagName()
|
XMLTag |
getInnerDocument()
|
java.lang.String |
getInnerText()
|
java.lang.String |
getPefix(java.lang.String namespaceURI)
Get the prefix of a namespace |
java.lang.String[] |
getPefixes(java.lang.String namespaceURI)
Get all bound prefixes of a namespace |
java.lang.String |
getText()
|
java.lang.String |
getText(java.lang.String relativeXpath,
java.lang.Object... arguments)
Get the text of a sepcific node |
java.lang.String |
getTextOrCDATA()
|
java.lang.String |
getTextOrCDATA(java.lang.String relativeXpath,
java.lang.Object... arguments)
Get the text of a sepcific node |
XMLTag |
gotoChild()
Go to the only child element of the curent node. |
XMLTag |
gotoChild(int i)
Go to the Nth child of the curent node. |
XMLTag |
gotoChild(java.lang.String nodeName)
Go to the child found with given node name |
XMLTag |
gotoFirstChild()
Go to the first child element of the curent node. |
XMLTag |
gotoFirstChild(java.lang.String name)
Go to the first child occurance found having given name |
XMLTag |
gotoLastChild()
Go to the lastest child element of the curent node. |
XMLTag |
gotoLastChild(java.lang.String name)
Go to the last child occurance found having given name |
XMLTag |
gotoParent()
Go to parent tag. |
XMLTag |
gotoRoot()
Go to document root tag |
XMLTag |
gotoTag(java.lang.String relativeXpath,
java.lang.Object... arguments)
Go to a specific node |
boolean |
hasAttribute(java.lang.String name)
Check wheter current tag contains an atribute |
boolean |
hasAttribute(java.lang.String name,
java.lang.String relativeXpath,
java.lang.Object... arguments)
Check if targeted tag has an attribute of given name |
boolean |
hasTag(java.lang.String relativeXpath,
java.lang.Object... arguments)
Check if a tag exist in the document |
static XMLDocBuilder |
newDocument(boolean ignoreNamespaces)
|
java.lang.Boolean |
rawXpathBoolean(java.lang.String relativeXpath,
java.lang.Object... arguments)
Execute an XPath expression directly using the Java XPath API, from the current node. |
org.w3c.dom.Node |
rawXpathNode(java.lang.String relativeXpath,
java.lang.Object... arguments)
Execute an XPath expression directly using the Java XPath API, from the current node. |
org.w3c.dom.NodeList |
rawXpathNodeSet(java.lang.String relativeXpath,
java.lang.Object... arguments)
Execute an XPath expression directly using the Java XPath API, from the current node. |
java.lang.Number |
rawXpathNumber(java.lang.String relativeXpath,
java.lang.Object... arguments)
Execute an XPath expression directly using the Java XPath API, from the current node. |
java.lang.String |
rawXpathString(java.lang.String relativeXpath,
java.lang.Object... arguments)
Execute an XPath expression directly using the Java XPath API, from the current node. |
XMLTag |
renameTo(java.lang.String newNodeName)
Replace current element name by another name |
XMLTag |
setAttribute(java.lang.String name,
java.lang.String value)
Sets the new value on an existign attribute, and remains on the current tag. |
XMLTag |
setAttribute(java.lang.String name,
java.lang.String value,
java.lang.String relativeXpath,
java.lang.Object... arguments)
Sets the new value on a targetted node's attribute, and remains on the current tag. |
XMLTag |
setAttributeIfExist(java.lang.String name,
java.lang.String value)
Sets the new value on an attribute, and remains on the current tag. |
XMLTag |
setAttributeIfExist(java.lang.String name,
java.lang.String value,
java.lang.String relativeXpath,
java.lang.Object... arguments)
Sets the new value on a targetted node's attribute, and remains on the current tag. |
XMLTag |
setCDATA(java.lang.String data)
Set the cdata in the current node. |
XMLTag |
setCDATA(java.lang.String data,
java.lang.String relativeXpath,
java.lang.Object... arguments)
Set the cdata in the targetted node. |
XMLTag |
setCDATAIfExist(java.lang.String data,
java.lang.String relativeXpath,
java.lang.Object... arguments)
Set the cdata in the targetted node. |
XMLTag |
setText(java.lang.String text)
Set the text in the current node. |
XMLTag |
setText(java.lang.String text,
java.lang.String relativeXpath,
java.lang.Object... arguments)
Set the text in the targetted node. |
XMLTag |
setTextIfExist(java.lang.String text,
java.lang.String relativeXpath,
java.lang.Object... arguments)
Set the text in the targetted node. |
byte[] |
toBytes()
|
byte[] |
toBytes(java.lang.String encoding)
|
org.w3c.dom.Document |
toDocument()
|
java.io.OutputStream |
toOutputStream()
|
java.io.OutputStream |
toOutputStream(java.lang.String encoding)
|
javax.xml.transform.Result |
toResult()
|
XMLTag |
toResult(javax.xml.transform.Result out)
Converts this document to the result provided |
XMLTag |
toResult(javax.xml.transform.Result out,
java.lang.String encoding)
Converts this document to the result provided, overriding default encoding of xml document |
javax.xml.transform.Result |
toResult(java.lang.String encoding)
|
javax.xml.transform.Source |
toSource()
|
XMLTag |
toStream(java.io.OutputStream out)
Write this document to a stream |
XMLTag |
toStream(java.io.OutputStream out,
java.lang.String encoding)
Write this document to a stream |
XMLTag |
toStream(java.io.Writer out)
Write this document to a stream |
XMLTag |
toStream(java.io.Writer out,
java.lang.String encoding)
Write this document to a stream |
java.lang.String |
toString()
|
java.lang.String |
toString(java.lang.String encoding)
|
java.io.Writer |
toWriter()
|
java.io.Writer |
toWriter(java.lang.String encoding)
|
ValidationResult |
validate(javax.xml.transform.Source... schemas)
Validate this document against specifief schemas |
ValidationResult |
validate(java.net.URL... schemaLocations)
Validate this document against specifief schemas |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public javax.xml.namespace.NamespaceContext getContext()
getContext
in interface XMLTag
public boolean hasAttribute(java.lang.String name)
XMLTag
hasAttribute
in interface XMLTag
name
- Attribute name
public boolean hasAttribute(java.lang.String name, java.lang.String relativeXpath, java.lang.Object... arguments)
XMLTag
hasAttribute
in interface XMLTag
name
- the name of the attributerelativeXpath
- XPath that target the tagarguments
- optional arguments of xpath expression. Uses String.format() to build XPath expression.
public boolean hasTag(java.lang.String relativeXpath, java.lang.Object... arguments)
XMLTag
hasTag
in interface XMLTag
relativeXpath
- XPath expression where the tag should be locatedarguments
- XPath arguments. Uses String.format() to build XPath expression.
public XMLTag forEachChild(CallBack callBack)
XMLTag
forEachChild
in interface XMLTag
callBack
- Callback method to run after the current tag of the document has changed to a child
public XMLTag forEach(CallBack callBack, java.lang.String relativeXpath, java.lang.Object... arguments)
XMLTag
forEach
in interface XMLTag
callBack
- Callback method to run after the current tag of the document has changed to a childrelativeXpath
- XXath expression that select the nodearguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.
public XMLTag forEach(java.lang.String xpath, CallBack callBack)
forEach
in interface XMLTag
public java.lang.String rawXpathString(java.lang.String relativeXpath, java.lang.Object... arguments)
XMLTag
rawXpathString
in interface XMLTag
relativeXpath
- The XPath expressionarguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.
XPathConstants.STRING
return typepublic java.lang.Number rawXpathNumber(java.lang.String relativeXpath, java.lang.Object... arguments)
XMLTag
rawXpathNumber
in interface XMLTag
relativeXpath
- The XPath expressionarguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.
XPathConstants.NUMBER
return typepublic java.lang.Boolean rawXpathBoolean(java.lang.String relativeXpath, java.lang.Object... arguments)
XMLTag
rawXpathBoolean
in interface XMLTag
relativeXpath
- The XPath expressionarguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.
XPathConstants.BOOLEAN
return typepublic org.w3c.dom.Node rawXpathNode(java.lang.String relativeXpath, java.lang.Object... arguments)
XMLTag
rawXpathNode
in interface XMLTag
relativeXpath
- The XPath expressionarguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.
XPathConstants.NODE
return typepublic org.w3c.dom.NodeList rawXpathNodeSet(java.lang.String relativeXpath, java.lang.Object... arguments)
XMLTag
rawXpathNodeSet
in interface XMLTag
relativeXpath
- The XPath expressionarguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.
XPathConstants.NODESET
return typepublic java.lang.String getPefix(java.lang.String namespaceURI)
XMLTag
getPefix
in interface XMLTag
namespaceURI
- The URI of the namespace
javadoc
)public java.lang.String[] getPefixes(java.lang.String namespaceURI)
XMLTag
getPefixes
in interface XMLTag
namespaceURI
- The URI of the namespace
public XMLTag addNamespace(java.lang.String prefix, java.lang.String namespaceURI)
XMLTag
addNamespace
in interface XMLTag
prefix
- The prefix of the namespacenamespaceURI
- The URI of the namespace
public XMLTag addDocument(XMLTag tag)
XMLTag
XMLTag
instance under the current tag. The whole document will be inserted.
addDocument
in interface XMLTag
tag
- The XMLTag
instance to insert
public XMLTag addDocument(org.w3c.dom.Document doc)
XMLTag
Document
instance under the current tag
addDocument
in interface XMLTag
doc
- The Document
instance to insert
public XMLTag addTag(XMLTag tag)
XMLTag
XMLTag
tag hierarchy under the current tag. Only the current tag of the given document
will be inserted with its hierarchy, not the whole document.
addTag
in interface XMLTag
tag
- The XMLTag
current tag hierarchy to insert
public XMLTag addTag(org.w3c.dom.Element tag)
XMLTag
Element
instance and its hierarchy under the current tag
addTag
in interface XMLTag
tag
- The Element
instance to insert
public XMLTag addTag(java.lang.String name)
XMLTag
addTag
in interface XMLTag
name
- Name of the element to add
public XMLTag addAttribute(java.lang.String name, java.lang.String value)
XMLTag
addAttribute
in interface XMLTag
name
- Name of the attribute to addvalue
- value of the attribute to add
public XMLTag addAttribute(org.w3c.dom.Attr attr)
XMLTag
addAttribute
in interface XMLTag
attr
- The attribute to insert
public XMLTag addText(java.lang.String text)
XMLTag
addTag("name").addText("Bob")addTag("sex").addText("M")addTag("age").addText("30")
<name>Bob</name><sex>M</sex><age>30</age>
addText
in interface XMLTag
text
- the text to add
public XMLTag addText(org.w3c.dom.Text text)
XMLTag
addText
in interface XMLTag
text
- The node to insert
public XMLTag addCDATA(java.lang.String data)
XMLTag
addTag("name").addCDATA("Bob")addTag("sex").addCDATA("M")addTag("age").addCDATA("30")
<name><![CDATA[Bob]]></name><sex><![CDATA[M]]></sex><age><![CDATA[30]]></age>
addCDATA
in interface XMLTag
data
- the data to add
public XMLTag addCDATA(org.w3c.dom.CDATASection data)
XMLTag
addCDATA
in interface XMLTag
data
- The node to insert
public XMLTag delete()
XMLTag
delete
in interface XMLTag
public XMLTag deleteChilds()
XMLTag
deleteChilds
in interface XMLTag
public XMLTag deleteAttributes()
XMLTag
deleteAttributes
in interface XMLTag
public XMLTag deleteAttribute(java.lang.String name)
XMLTag
deleteAttribute
in interface XMLTag
name
- attribute name
public XMLTag deleteAttributeIfExists(java.lang.String name)
XMLTag
deleteAttributeIfExists
in interface XMLTag
name
- attribute name
public XMLTag renameTo(java.lang.String newNodeName)
XMLTag
renameTo
in interface XMLTag
newNodeName
- New name of the tag
public XMLTag deletePrefixes()
XMLTag
deletePrefixes
in interface XMLTag
public XMLTag getInnerDocument()
getInnerDocument
in interface XMLTag
public java.lang.String getInnerText()
getInnerText
in interface XMLTag
public XMLTag gotoParent()
XMLTag
gotoParent
in interface XMLTag
public XMLTag gotoRoot()
XMLTag
gotoRoot
in interface XMLTag
public XMLTag gotoChild()
XMLTag
gotoChild
in interface XMLTag
public XMLTag gotoChild(int i)
XMLTag
gotoChild
in interface XMLTag
i
- index of the child, from 1 to child element number
public XMLTag gotoChild(java.lang.String nodeName)
XMLTag
gotoChild
in interface XMLTag
nodeName
- name of the child to find.
public XMLTag gotoFirstChild() throws XMLDocumentException
XMLTag
gotoFirstChild
in interface XMLTag
XMLDocumentException
- If the current node has no child at allpublic XMLTag gotoFirstChild(java.lang.String name) throws XMLDocumentException
XMLTag
gotoFirstChild
in interface XMLTag
name
- Name of the child to go at
XMLDocumentException
- If the current node has no child at allpublic XMLTag gotoLastChild() throws XMLDocumentException
XMLTag
gotoLastChild
in interface XMLTag
XMLDocumentException
- If the current node has no child at allpublic XMLTag gotoLastChild(java.lang.String name) throws XMLDocumentException
XMLTag
gotoLastChild
in interface XMLTag
name
- Name of the child to go at
XMLDocumentException
- If the current node has no child at allpublic XMLTag gotoTag(java.lang.String relativeXpath, java.lang.Object... arguments)
XMLTag
gotoTag
in interface XMLTag
relativeXpath
- XPath expresionarguments
- to be replaced in xpath expression before compiling. Uses String.format() to build XPath expression.
public org.w3c.dom.Element getCurrentTag()
getCurrentTag
in interface XMLTag
public int getChildCount()
getChildCount
in interface XMLTag
public java.lang.Iterable<XMLTag> getChilds()
XMLTag
XMLTag tag = XMLDoc.newDocument(true)
.addRoot("root").addTag("a")
.gotoParent().addTag("b")
.gotoParent().addTag("c")
.gotoRoot();
assertEquals(tag.getCurrentTagName(), "root");
for (XMLTag xmlTag : tag.getChilds()) {
if(xmlTag.getCurrentTagName().equals("b")) {
break;
}
}
assertEquals(tag.getCurrentTagName(), "b");
XMLTag tag = XMLDoc.newDocument(true)
.addRoot("root").addTag("a")
.gotoParent().addTag("b")
.gotoParent().addTag("c")
.gotoRoot();
assertEquals(tag.getCurrentTagName(), "root");
for (XMLTag xmlTag : tag.getChilds()) {
System.out.println(xmlTag.getCurrentTagName());
}
assertEquals(tag.getCurrentTagName(), "root");
getChilds
in interface XMLTag
public java.lang.Iterable<XMLTag> getChilds(java.lang.String relativeXpath, java.lang.Object... arguments)
XMLTag
getChilds
in interface XMLTag
relativeXpath
- XPath to select tagsarguments
- XPath arguments
public java.util.List<org.w3c.dom.Element> getChildElement()
getChildElement
in interface XMLTag
public java.lang.String getCurrentTagName()
getCurrentTagName
in interface XMLTag
public java.lang.String getCurrentTagLocation()
getCurrentTagLocation
in interface XMLTag
public java.lang.String getAttribute(java.lang.String name)
XMLTag
getAttribute
in interface XMLTag
name
- attribute name
public java.lang.String findAttribute(java.lang.String name)
XMLTag
findAttribute
in interface XMLTag
name
- attribute name
public java.lang.String getAttribute(java.lang.String name, java.lang.String relativeXpath, java.lang.Object... arguments)
XMLTag
getAttribute
in interface XMLTag
name
- attribute namerelativeXpath
- XPath expressionarguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.
public java.lang.String findAttribute(java.lang.String name, java.lang.String relativeXpath, java.lang.Object... arguments) throws XMLDocumentException
XMLTag
findAttribute
in interface XMLTag
name
- attribute namerelativeXpath
- XPath expressionarguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.
XMLDocumentException
- targetted node does not exist or XPath expression is invalidpublic java.lang.String[] getAttributeNames()
getAttributeNames
in interface XMLTag
public java.lang.String getText(java.lang.String relativeXpath, java.lang.Object... arguments)
XMLTag
getText
in interface XMLTag
relativeXpath
- XPath expression that select the nodearguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.
public java.lang.String getText()
getText
in interface XMLTag
public java.lang.String getTextOrCDATA()
getTextOrCDATA
in interface XMLTag
public java.lang.String getTextOrCDATA(java.lang.String relativeXpath, java.lang.Object... arguments) throws XMLDocumentException
XMLTag
getTextOrCDATA
in interface XMLTag
relativeXpath
- XPath expression that select the nodearguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.
XMLDocumentException
- If the XPath expression is not valid or if the node does not existpublic java.lang.String getCDATAorText()
getCDATAorText
in interface XMLTag
public java.lang.String getCDATAorText(java.lang.String relativeXpath, java.lang.Object... arguments) throws XMLDocumentException
XMLTag
getCDATAorText
in interface XMLTag
relativeXpath
- XPath expression that select the nodearguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.
XMLDocumentException
- If the XPath expression is not valid or if the node does not existpublic java.lang.String getCDATA(java.lang.String relativeXpath, java.lang.Object... arguments)
XMLTag
getCDATA
in interface XMLTag
relativeXpath
- XPath expression that select the nodearguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.
public java.lang.String getCDATA()
getCDATA
in interface XMLTag
public org.w3c.dom.Document toDocument()
toDocument
in interface XMLTag
public javax.xml.transform.Source toSource()
toSource
in interface XMLTag
Source
public java.lang.String toString()
toString
in interface XMLTag
toString
in class java.lang.Object
public java.lang.String toString(java.lang.String encoding)
toString
in interface XMLTag
encoding
- destination encoding of XML document
public byte[] toBytes()
toBytes
in interface XMLTag
public byte[] toBytes(java.lang.String encoding)
toBytes
in interface XMLTag
encoding
- The encoding to use
public XMLTag toStream(java.io.OutputStream out)
XMLTag
toStream
in interface XMLTag
out
- The output result
public XMLTag toStream(java.io.OutputStream out, java.lang.String encoding)
XMLTag
toStream
in interface XMLTag
out
- The output resultencoding
- The new encoding
public XMLTag toStream(java.io.Writer out)
XMLTag
toStream
in interface XMLTag
out
- The output result
public XMLTag toStream(java.io.Writer out, java.lang.String encoding)
XMLTag
toStream
in interface XMLTag
out
- The output resultencoding
- The new encoding
public javax.xml.transform.Result toResult()
toResult
in interface XMLTag
Result
representation of this document. Useful when using web services for example.public javax.xml.transform.Result toResult(java.lang.String encoding)
toResult
in interface XMLTag
encoding
- The new encoding
Result
representation of this document. Useful when using web services for example.public java.io.OutputStream toOutputStream()
toOutputStream
in interface XMLTag
public java.io.OutputStream toOutputStream(java.lang.String encoding)
toOutputStream
in interface XMLTag
encoding
- The new encoding
public java.io.Writer toWriter()
toWriter
in interface XMLTag
public java.io.Writer toWriter(java.lang.String encoding)
toWriter
in interface XMLTag
encoding
- The new encoding
public XMLTag toResult(javax.xml.transform.Result out)
XMLTag
toResult
in interface XMLTag
out
- The output result
public XMLTag toResult(javax.xml.transform.Result out, java.lang.String encoding)
XMLTag
toResult
in interface XMLTag
out
- The output resultencoding
- The new encoding
public ValidationResult validate(javax.xml.transform.Source... schemas)
XMLTag
validate
in interface XMLTag
schemas
- A list of schemas
public ValidationResult validate(java.net.URL... schemaLocations)
XMLTag
validate
in interface XMLTag
schemaLocations
- A list of schemas
public XMLTag duplicate()
duplicate
in interface XMLTag
public XMLTag setText(java.lang.String text)
XMLTag
gotoChild("name").setText("Bob").gotoChild("sex").setText("M").gotoChild("age").setText("30")
<name>Bob</name><sex>M</sex><age>30</age>
setText
in interface XMLTag
text
- text to put under this node
public XMLTag setText(java.lang.String text, java.lang.String relativeXpath, java.lang.Object... arguments) throws XMLDocumentException
XMLTag
setText
in interface XMLTag
text
- text to put under this noderelativeXpath
- XPath expression that select the nodearguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.
XMLDocumentException
- If the XPath expression is invalid or if the node does not existpublic XMLTag setTextIfExist(java.lang.String text, java.lang.String relativeXpath, java.lang.Object... arguments) throws XMLDocumentException
XMLTag
setTextIfExist
in interface XMLTag
text
- text to put under this noderelativeXpath
- XPath expression that select the nodearguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.
XMLDocumentException
- If the XPath expression is invalidpublic XMLTag setCDATA(java.lang.String data)
XMLTag
gotoChild("name").setText("Bob").gotoChild("sex").setText("M").gotoChild("age").setText("30")
<name>Bob</name><sex>M</sex><age>30</age>
setCDATA
in interface XMLTag
data
- text to put under this node in a cdata section
public XMLTag setCDATA(java.lang.String data, java.lang.String relativeXpath, java.lang.Object... arguments) throws XMLDocumentException
XMLTag
setCDATA
in interface XMLTag
data
- text to put under this node in a cdata sectionrelativeXpath
- XPath expression that select the nodearguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.
XMLDocumentException
- If the XPath expression is invalid or if the node does not existpublic XMLTag setCDATAIfExist(java.lang.String data, java.lang.String relativeXpath, java.lang.Object... arguments) throws XMLDocumentException
XMLTag
setCDATAIfExist
in interface XMLTag
data
- text to put under this node in a cdata sectionrelativeXpath
- XPath expression that select the nodearguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.
XMLDocumentException
- If the XPath expression is invalidpublic XMLTag setAttribute(java.lang.String name, java.lang.String value) throws XMLDocumentException
XMLTag
setAttribute
in interface XMLTag
name
- attribute namevalue
- new attribute'svalue
XMLDocumentException
- If the attribute does not existpublic XMLTag setAttributeIfExist(java.lang.String name, java.lang.String value)
XMLTag
setAttributeIfExist
in interface XMLTag
name
- attribute namevalue
- new attribute value
public XMLTag setAttribute(java.lang.String name, java.lang.String value, java.lang.String relativeXpath, java.lang.Object... arguments) throws XMLDocumentException
XMLTag
setAttribute
in interface XMLTag
name
- attribute namevalue
- new attribute's valuerelativeXpath
- XPath expressionarguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.
XMLDocumentException
- Attribute does not exist, targetted node does not exit, or XPath expression is invalidpublic XMLTag setAttributeIfExist(java.lang.String name, java.lang.String value, java.lang.String relativeXpath, java.lang.Object... arguments) throws XMLDocumentException
XMLTag
setAttributeIfExist
in interface XMLTag
name
- attribute namevalue
- new attribute's valuerelativeXpath
- XPath expressionarguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.
XMLDocumentException
- XPath expression is invalid or targetted node does not existpublic static XMLDocBuilder newDocument(boolean ignoreNamespaces)
public static XMLTag from(org.w3c.dom.Node node, boolean ignoreNamespaces)
public static XMLTag from(org.xml.sax.InputSource source, boolean ignoreNamespaces)
public static XMLTag from(java.io.Reader reader, boolean ignoreNamespaces)
public static XMLTag from(java.io.InputStream is, boolean ignoreNamespaces)
public static XMLTag from(java.io.File file, boolean ignoreNamespaces)
public static XMLTag from(java.net.URL xmlLocation, boolean ignoreNamespaces)
public static XMLTag from(java.lang.String xmlData, boolean ignoreNamespaces)
public static XMLTag from(javax.xml.transform.Source source, boolean ignoreNamespaces)
public static XMLTag from(XMLTag tag, boolean ignoreNamespaces)
public static XMLTag fromCurrentTag(XMLTag tag, boolean ignoreNamespaces)
XMLTag
instance from the hierarchy under the current tag. The current tag becomes the root tag.
tag
- The current XML Tag positionned to the new root tagignoreNamespaces
- Wheter to build a namespace aware document
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |