|
|||||||||
| 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 XMLTagpublic boolean hasAttribute(java.lang.String name)
XMLTag
hasAttribute in interface XMLTagname - Attribute name
public boolean hasAttribute(java.lang.String name,
java.lang.String relativeXpath,
java.lang.Object... arguments)
XMLTag
hasAttribute in interface XMLTagname - 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 XMLTagrelativeXpath - 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 XMLTagcallBack - 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 XMLTagcallBack - 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 XMLTagrelativeXpath - The XPath expressionarguments - facultative Xpath expression arguments. Uses String.format() to build XPath expression.
XPathConstants.STRING return type
public java.lang.Number rawXpathNumber(java.lang.String relativeXpath,
java.lang.Object... arguments)
XMLTag
rawXpathNumber in interface XMLTagrelativeXpath - The XPath expressionarguments - facultative Xpath expression arguments. Uses String.format() to build XPath expression.
XPathConstants.NUMBER return type
public java.lang.Boolean rawXpathBoolean(java.lang.String relativeXpath,
java.lang.Object... arguments)
XMLTag
rawXpathBoolean in interface XMLTagrelativeXpath - The XPath expressionarguments - facultative Xpath expression arguments. Uses String.format() to build XPath expression.
XPathConstants.BOOLEAN return type
public org.w3c.dom.Node rawXpathNode(java.lang.String relativeXpath,
java.lang.Object... arguments)
XMLTag
rawXpathNode in interface XMLTagrelativeXpath - The XPath expressionarguments - facultative Xpath expression arguments. Uses String.format() to build XPath expression.
XPathConstants.NODE return type
public org.w3c.dom.NodeList rawXpathNodeSet(java.lang.String relativeXpath,
java.lang.Object... arguments)
XMLTag
rawXpathNodeSet in interface XMLTagrelativeXpath - 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 XMLTagnamespaceURI - The URI of the namespace
javadoc)public java.lang.String[] getPefixes(java.lang.String namespaceURI)
XMLTag
getPefixes in interface XMLTagnamespaceURI - The URI of the namespace
public XMLTag addNamespace(java.lang.String prefix,
java.lang.String namespaceURI)
XMLTag
addNamespace in interface XMLTagprefix - The prefix of the namespacenamespaceURI - The URI of the namespace
public XMLTag addDocument(XMLTag tag)
XMLTagXMLTag instance under the current tag. The whole document will be inserted.
addDocument in interface XMLTagtag - The XMLTag instance to insert
public XMLTag addDocument(org.w3c.dom.Document doc)
XMLTagDocument instance under the current tag
addDocument in interface XMLTagdoc - The Document instance to insert
public XMLTag addTag(XMLTag tag)
XMLTagXMLTag 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 XMLTagtag - The XMLTag current tag hierarchy to insert
public XMLTag addTag(org.w3c.dom.Element tag)
XMLTagElement instance and its hierarchy under the current tag
addTag in interface XMLTagtag - The Element instance to insert
public XMLTag addTag(java.lang.String name)
XMLTag
addTag in interface XMLTagname - Name of the element to add
public XMLTag addAttribute(java.lang.String name,
java.lang.String value)
XMLTag
addAttribute in interface XMLTagname - Name of the attribute to addvalue - value of the attribute to add
public XMLTag addAttribute(org.w3c.dom.Attr attr)
XMLTag
addAttribute in interface XMLTagattr - The attribute to insert
public XMLTag addText(java.lang.String text)
XMLTagaddTag("name").addText("Bob")addTag("sex").addText("M")addTag("age").addText("30")
<name>Bob</name><sex>M</sex><age>30</age>
addText in interface XMLTagtext - the text to add
public XMLTag addText(org.w3c.dom.Text text)
XMLTag
addText in interface XMLTagtext - The node to insert
public XMLTag addCDATA(java.lang.String data)
XMLTagaddTag("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 XMLTagdata - the data to add
public XMLTag addCDATA(org.w3c.dom.CDATASection data)
XMLTag
addCDATA in interface XMLTagdata - The node to insert
public XMLTag delete()
XMLTag
delete in interface XMLTagpublic XMLTag deleteChilds()
XMLTag
deleteChilds in interface XMLTagpublic XMLTag deleteAttributes()
XMLTag
deleteAttributes in interface XMLTagpublic XMLTag deleteAttribute(java.lang.String name)
XMLTag
deleteAttribute in interface XMLTagname - attribute name
public XMLTag deleteAttributeIfExists(java.lang.String name)
XMLTag
deleteAttributeIfExists in interface XMLTagname - attribute name
public XMLTag renameTo(java.lang.String newNodeName)
XMLTag
renameTo in interface XMLTagnewNodeName - New name of the tag
public XMLTag deletePrefixes()
XMLTag
deletePrefixes in interface XMLTagpublic XMLTag getInnerDocument()
getInnerDocument in interface XMLTagpublic java.lang.String getInnerText()
getInnerText in interface XMLTagpublic XMLTag gotoParent()
XMLTag
gotoParent in interface XMLTagpublic XMLTag gotoRoot()
XMLTag
gotoRoot in interface XMLTagpublic XMLTag gotoChild()
XMLTag
gotoChild in interface XMLTagpublic XMLTag gotoChild(int i)
XMLTag
gotoChild in interface XMLTagi - index of the child, from 1 to child element number
public XMLTag gotoChild(java.lang.String nodeName)
XMLTag
gotoChild in interface XMLTagnodeName - name of the child to find.
public XMLTag gotoFirstChild()
throws XMLDocumentException
XMLTag
gotoFirstChild in interface XMLTagXMLDocumentException - If the current node has no child at all
public XMLTag gotoFirstChild(java.lang.String name)
throws XMLDocumentException
XMLTag
gotoFirstChild in interface XMLTagname - Name of the child to go at
XMLDocumentException - If the current node has no child at all
public XMLTag gotoLastChild()
throws XMLDocumentException
XMLTag
gotoLastChild in interface XMLTagXMLDocumentException - If the current node has no child at all
public XMLTag gotoLastChild(java.lang.String name)
throws XMLDocumentException
XMLTag
gotoLastChild in interface XMLTagname - Name of the child to go at
XMLDocumentException - If the current node has no child at all
public XMLTag gotoTag(java.lang.String relativeXpath,
java.lang.Object... arguments)
XMLTag
gotoTag in interface XMLTagrelativeXpath - 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 XMLTagpublic int getChildCount()
getChildCount in interface XMLTagpublic java.lang.Iterable<XMLTag> getChilds()
XMLTagXMLTag 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 XMLTagrelativeXpath - XPath to select tagsarguments - XPath arguments
public java.util.List<org.w3c.dom.Element> getChildElement()
getChildElement in interface XMLTagpublic java.lang.String getCurrentTagName()
getCurrentTagName in interface XMLTagpublic java.lang.String getCurrentTagLocation()
getCurrentTagLocation in interface XMLTagpublic java.lang.String getAttribute(java.lang.String name)
XMLTag
getAttribute in interface XMLTagname - attribute name
public java.lang.String findAttribute(java.lang.String name)
XMLTag
findAttribute in interface XMLTagname - attribute name
public java.lang.String getAttribute(java.lang.String name,
java.lang.String relativeXpath,
java.lang.Object... arguments)
XMLTag
getAttribute in interface XMLTagname - 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 XMLTagname - 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 XMLTagrelativeXpath - 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 XMLTagpublic 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 XMLTagrelativeXpath - 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 XMLTagrelativeXpath - 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 exist
public java.lang.String getCDATA(java.lang.String relativeXpath,
java.lang.Object... arguments)
XMLTag
getCDATA in interface XMLTagrelativeXpath - 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 XMLTagpublic org.w3c.dom.Document toDocument()
toDocument in interface XMLTagpublic javax.xml.transform.Source toSource()
toSource in interface XMLTagSourcepublic java.lang.String toString()
toString in interface XMLTagtoString in class java.lang.Objectpublic java.lang.String toString(java.lang.String encoding)
toString in interface XMLTagencoding - destination encoding of XML document
public byte[] toBytes()
toBytes in interface XMLTagpublic byte[] toBytes(java.lang.String encoding)
toBytes in interface XMLTagencoding - The encoding to use
public XMLTag toStream(java.io.OutputStream out)
XMLTag
toStream in interface XMLTagout - The output result
public XMLTag toStream(java.io.OutputStream out,
java.lang.String encoding)
XMLTag
toStream in interface XMLTagout - The output resultencoding - The new encoding
public XMLTag toStream(java.io.Writer out)
XMLTag
toStream in interface XMLTagout - The output result
public XMLTag toStream(java.io.Writer out,
java.lang.String encoding)
XMLTag
toStream in interface XMLTagout - The output resultencoding - The new encoding
public javax.xml.transform.Result toResult()
toResult in interface XMLTagResult representation of this document. Useful when using web services for example.public javax.xml.transform.Result toResult(java.lang.String encoding)
toResult in interface XMLTagencoding - The new encoding
Result representation of this document. Useful when using web services for example.public java.io.OutputStream toOutputStream()
toOutputStream in interface XMLTagpublic java.io.OutputStream toOutputStream(java.lang.String encoding)
toOutputStream in interface XMLTagencoding - The new encoding
public java.io.Writer toWriter()
toWriter in interface XMLTagpublic java.io.Writer toWriter(java.lang.String encoding)
toWriter in interface XMLTagencoding - The new encoding
public XMLTag toResult(javax.xml.transform.Result out)
XMLTag
toResult in interface XMLTagout - The output result
public XMLTag toResult(javax.xml.transform.Result out,
java.lang.String encoding)
XMLTag
toResult in interface XMLTagout - The output resultencoding - The new encoding
public ValidationResult validate(javax.xml.transform.Source... schemas)
XMLTag
validate in interface XMLTagschemas - A list of schemas
public ValidationResult validate(java.net.URL... schemaLocations)
XMLTag
validate in interface XMLTagschemaLocations - A list of schemas
public XMLTag duplicate()
duplicate in interface XMLTagpublic XMLTag setText(java.lang.String text)
XMLTaggotoChild("name").setText("Bob").gotoChild("sex").setText("M").gotoChild("age").setText("30")
<name>Bob</name><sex>M</sex><age>30</age>
setText in interface XMLTagtext - 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 XMLTagtext - 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 exist
public XMLTag setTextIfExist(java.lang.String text,
java.lang.String relativeXpath,
java.lang.Object... arguments)
throws XMLDocumentException
XMLTag
setTextIfExist in interface XMLTagtext - 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)
XMLTaggotoChild("name").setText("Bob").gotoChild("sex").setText("M").gotoChild("age").setText("30")
<name>Bob</name><sex>M</sex><age>30</age>
setCDATA in interface XMLTagdata - 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 XMLTagdata - 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 exist
public XMLTag setCDATAIfExist(java.lang.String data,
java.lang.String relativeXpath,
java.lang.Object... arguments)
throws XMLDocumentException
XMLTag
setCDATAIfExist in interface XMLTagdata - 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
public XMLTag setAttribute(java.lang.String name,
java.lang.String value)
throws XMLDocumentException
XMLTag
setAttribute in interface XMLTagname - attribute namevalue - new attribute'svalue
XMLDocumentException - If the attribute does not exist
public XMLTag setAttributeIfExist(java.lang.String name,
java.lang.String value)
XMLTag
setAttributeIfExist in interface XMLTagname - 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 XMLTagname - 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 invalid
public XMLTag setAttributeIfExist(java.lang.String name,
java.lang.String value,
java.lang.String relativeXpath,
java.lang.Object... arguments)
throws XMLDocumentException
XMLTag
setAttributeIfExist in interface XMLTagname - 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 | ||||||||