|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectfr.tireme.shared.xml.dom.DOMUtils
public class DOMUtils
Set of utilities enabling to work better with DOM trees.
| Method Summary | |
|---|---|
java.lang.String |
attrToString(org.w3c.dom.Element element)
attrToString : serialize element attributes |
org.w3c.dom.Element |
elemFromStr(java.lang.String xmlStr)
Description of the Method |
org.w3c.dom.Element |
elemFromStr(java.lang.String xmlStr,
boolean validate)
|
org.w3c.dom.Node |
elemFromStr(java.lang.String xmlStr,
org.w3c.dom.Document doc)
Description of the Method |
java.lang.String |
getAttrValue(org.w3c.dom.Node node,
java.lang.String value)
Gets the attr attribute of the DOMUtils class |
org.w3c.dom.Element |
getChildByName(org.w3c.dom.Element element,
java.lang.String name)
getChildByName |
java.lang.String |
getChildContent(org.w3c.dom.Element element,
java.lang.String name)
getChildContent |
org.w3c.dom.Element |
getFirstAncestorElement(org.w3c.dom.Element element,
java.lang.String elemName)
getParentElement |
org.w3c.dom.Element |
getFirstAncestorElement(org.w3c.dom.Element element,
java.lang.String elemName,
java.lang.String attName)
getParentElement having a specific node |
org.w3c.dom.Element |
getFirstElemChild(org.w3c.dom.Element element)
|
static DOMUtils |
getInstance()
|
org.w3c.dom.Element |
getNextSiblingElement(org.w3c.dom.Element element)
|
org.w3c.dom.Element |
getParentElement(org.w3c.dom.Element element)
getParentElement |
org.w3c.dom.Element |
getSiblingByAttr(org.w3c.dom.Element element,
java.lang.String name,
java.lang.String value)
getSiblingByAttr |
boolean |
hasAttr(org.w3c.dom.Node node,
java.lang.String value)
Test if a node has a specific attribute |
org.w3c.dom.Node |
importNode(org.w3c.dom.Document doc,
org.w3c.dom.Element element)
Description of the Method |
org.w3c.dom.Node |
importNode(org.w3c.dom.Document doc,
org.w3c.dom.Node child,
boolean doappend)
|
org.w3c.dom.Node |
importNode(org.w3c.dom.Node parent,
org.w3c.dom.Node child)
Description of the Method |
org.w3c.dom.Node |
importNode(org.w3c.dom.Node parent,
org.w3c.dom.Node child,
boolean doappend)
Description of the Method |
void |
importNodeInPlace(org.w3c.dom.Node parent,
org.w3c.dom.Node child,
boolean doappend,
org.w3c.dom.Node nodeToReplace)
Node remplacement using an imported node from an other Document |
org.w3c.dom.Document |
loadXML(java.lang.String source,
boolean validate)
Routine using DOM3ErrorHandler LS (Load and Save) |
java.lang.String |
normalize(java.lang.String s)
Normalizes and prints the given string. |
java.lang.String |
recContent(org.w3c.dom.Node node)
Get recursively all the text content of a DOM node tree Improvements needed : - take in account other things than soles PCDATA and elements such as CDATA sections and marked sections. |
void |
removeChildren(org.w3c.dom.Element element)
removeChildren |
void |
replaceNode(org.w3c.dom.Node oldNode,
org.w3c.dom.Node newNode)
Node remplacement in the same Document |
java.lang.String |
serialize(org.w3c.dom.Node n)
Serialize a dom document within a string |
java.lang.String |
serialize(org.w3c.dom.Node n,
boolean wantXMLDeclaration)
Serialize a dom document within a string enabling to say if an xml declaration is needed |
void |
serialize(org.w3c.dom.Node doc,
java.io.File outFile)
DOM node serialization using a JAVAX dummy transformer |
void |
serialize(org.w3c.dom.Node doc,
java.lang.String outFile)
DOM node serialization using a JAVAX dummy transformer |
java.lang.String |
serialize(org.w3c.dom.Node n,
java.lang.String doctypePublic,
java.lang.String doctypeSystem)
Description of the Method |
java.lang.String |
serialize(org.w3c.dom.Node n,
java.lang.String serializationCoding,
java.lang.String doctypePublic,
java.lang.String doctypeSystem)
Description of the Method |
void |
serialize(org.w3c.dom.Node n,
java.lang.String serializationCoding,
java.lang.String doctypePublic,
java.lang.String doctypeSystem,
java.io.File outputFile,
boolean wantXMLDeclaration)
Serialize to a file |
org.w3c.dom.Attr[] |
sortAttributes(org.w3c.dom.NamedNodeMap attrs)
Returns a sorted list of attributes. |
java.lang.String |
toString(org.w3c.dom.Element element)
dump a element |
java.lang.String |
toString(org.w3c.dom.Node node)
dump a node |
void |
validateXML(java.lang.String source)
Validate as DOM document from file system This vlidation is using JavaX interface (full compliant Xalan) In error case, error is thrown using exceptions otherwise, nothing is returned, the file is valid. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static DOMUtils getInstance()
public java.lang.String attrToString(org.w3c.dom.Element element)
element - dom element object
public org.w3c.dom.Element elemFromStr(java.lang.String xmlStr)
throws XmlException
xmlStr - Description of the Parameter
XmlException
public org.w3c.dom.Element elemFromStr(java.lang.String xmlStr,
boolean validate)
throws XmlException
XmlException
public org.w3c.dom.Node elemFromStr(java.lang.String xmlStr,
org.w3c.dom.Document doc)
throws XmlException
xmlStr - Description of the Parameterdoc - Description of the Parameter
XmlException
public org.w3c.dom.Element getChildByName(org.w3c.dom.Element element,
java.lang.String name)
element - dom elementname - name of a researched child element
public java.lang.String getChildContent(org.w3c.dom.Element element,
java.lang.String name)
throws StandardException
element - dom elementname - name of a researched child element
StandardException
public org.w3c.dom.Element getFirstAncestorElement(org.w3c.dom.Element element,
java.lang.String elemName)
element - dom elementelemName - String
public org.w3c.dom.Element getFirstAncestorElement(org.w3c.dom.Element element,
java.lang.String elemName,
java.lang.String attName)
element - dom elementelemName - StringattName - String
public org.w3c.dom.Element getFirstElemChild(org.w3c.dom.Element element)
element - Description of the Parameter
public org.w3c.dom.Element getNextSiblingElement(org.w3c.dom.Element element)
element - Description of the Parameter
public org.w3c.dom.Element getParentElement(org.w3c.dom.Element element)
element - dom element
public org.w3c.dom.Element getSiblingByAttr(org.w3c.dom.Element element,
java.lang.String name,
java.lang.String value)
element - dom elementname - name of attributevalue - value of attribute
public org.w3c.dom.Node importNode(org.w3c.dom.Document doc,
org.w3c.dom.Element element)
throws XmlException,
StandardException
doc - Description of the Parameterelement - Description of the Parameter
XmlException
StandardExceptionpublic java.lang.String normalize(java.lang.String s)
s - Description of the Parameter
public java.lang.String recContent(org.w3c.dom.Node node)
throws StandardException
Get recursively all the text content of a DOM node tree
node - The node to be explored
StandardExceptionpublic void removeChildren(org.w3c.dom.Element element)
element - dom element
public java.lang.String serialize(org.w3c.dom.Node n)
throws StandardException
n - node
StandardException
public java.lang.String serialize(org.w3c.dom.Node n,
boolean wantXMLDeclaration)
throws StandardException
n - nodewantXMLDeclaration - boolean
StandardException
public void serialize(org.w3c.dom.Node doc,
java.io.File outFile)
throws StandardException
doc - document to serializeoutFile - output valid filename
StandardException
public void serialize(org.w3c.dom.Node doc,
java.lang.String outFile)
throws StandardException
doc - document to serializeoutFile - output valid filename
StandardException
public java.lang.String serialize(org.w3c.dom.Node n,
java.lang.String doctypePublic,
java.lang.String doctypeSystem)
throws StandardException
n - nodedoctypePublic - Description of ParameterdoctypeSystem - Description of Parameter
StandardException
public java.lang.String serialize(org.w3c.dom.Node n,
java.lang.String serializationCoding,
java.lang.String doctypePublic,
java.lang.String doctypeSystem)
throws StandardException
n - nodeserializationCoding - Description of ParameterdoctypePublic - Description of ParameterdoctypeSystem - Description of Parameter
StandardException
public void serialize(org.w3c.dom.Node n,
java.lang.String serializationCoding,
java.lang.String doctypePublic,
java.lang.String doctypeSystem,
java.io.File outputFile,
boolean wantXMLDeclaration)
throws StandardException
n - NodeserializationCoding - StringdoctypePublic - StringdoctypeSystem - StringoutputFile - FilewantXMLDeclaration - boolean
StandardExceptionpublic org.w3c.dom.Attr[] sortAttributes(org.w3c.dom.NamedNodeMap attrs)
attrs - Description of the Parameter
public java.lang.String toString(org.w3c.dom.Element element)
throws StandardException
element - dom element object
StandardException
public java.lang.String toString(org.w3c.dom.Node node)
throws StandardException
node - dom node object
StandardException
public void validateXML(java.lang.String source)
throws java.io.IOException,
org.xml.sax.SAXException,
java.lang.Exception
This vlidation is using JavaX interface (full compliant Xalan)
In error case, error is thrown using exceptions otherwise, nothing is returned, the file is valid.
source - XML file Path
java.io.IOException
org.xml.sax.SAXException
java.lang.Exception
public org.w3c.dom.Document loadXML(java.lang.String source,
boolean validate)
throws StandardException
source - source template filevalidate - boolean
StandardException
public java.lang.String getAttrValue(org.w3c.dom.Node node,
java.lang.String value)
node - Nodevalue - attribute name where to get value
public boolean hasAttr(org.w3c.dom.Node node,
java.lang.String value)
node - Nodevalue - The attribute to check
public org.w3c.dom.Node importNode(org.w3c.dom.Document doc,
org.w3c.dom.Node child,
boolean doappend)
public org.w3c.dom.Node importNode(org.w3c.dom.Node parent,
org.w3c.dom.Node child)
parent - Description of Parameterchild - Description of Parameter
public org.w3c.dom.Node importNode(org.w3c.dom.Node parent,
org.w3c.dom.Node child,
boolean doappend)
parent - Description of Parameterchild - Description of Parameterdoappend - Description of Parameter
public void importNodeInPlace(org.w3c.dom.Node parent,
org.w3c.dom.Node child,
boolean doappend,
org.w3c.dom.Node nodeToReplace)
Document
parent - Nodechild - Nodedoappend - booleannodeToReplace - Node
public void replaceNode(org.w3c.dom.Node oldNode,
org.w3c.dom.Node newNode)
Document
oldNode - NodenewNode - Node
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||