|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--ocean.utils.XMLutils
The XMLutils class contains many utility methods that wrap the DOM,
causing many common tasks that take several lines of code to take one.
| Constructor Summary | |
XMLutils()
|
|
| Method Summary | |
static void |
attachAttrToNode(org.w3c.dom.Element e,
org.w3c.dom.Document d,
java.lang.String name,
java.lang.String val)
Create a named attribute with a value and attach it to an element. |
static void |
attachElemToNode(org.w3c.dom.Node n,
org.w3c.dom.Document d,
java.lang.String name)
Create a named element and attach it to a node . |
static void |
attachText(org.w3c.dom.Node n,
org.w3c.dom.Document d,
java.lang.String text)
Set a text value for an existing text node. |
static void |
attachTextToNode(org.w3c.dom.Node n,
org.w3c.dom.Document d,
java.lang.String name,
java.lang.String val)
Create a text, set its value and append it to a node. |
static org.w3c.dom.Element |
getAttachedElem(org.w3c.dom.Node n,
org.w3c.dom.Document d,
java.lang.String name)
Create a named element and attach it to a node, returning the created element |
static java.lang.String |
getAttrVal(org.w3c.dom.Node node,
java.lang.String val)
Search a Node for an attribute value. |
static org.w3c.dom.Node |
getChildByName(org.w3c.dom.Node node,
java.lang.String name)
Search for the first child node of a Node by name. |
static org.w3c.dom.Node |
getChildByType(org.w3c.dom.Node n,
short code)
Search a Node for the first child of a given type |
static org.w3c.dom.Node |
getChildElement(org.w3c.dom.Node node)
Search for the first child of a Node that is an Element. |
static java.util.Vector |
getChildrenByName(org.w3c.dom.Node node,
java.lang.String searchName)
Search for all children of a Node by name. |
static org.w3c.dom.Document |
getDOMDoc(java.lang.String docContent)
Construct an instance of the Document interface by parsing the
String representation of an XML document. |
static java.lang.String |
getNodeText(org.w3c.dom.Node node)
Get the text value of an element whose type is text. |
static org.w3c.dom.Node |
getSiblingByName(org.w3c.dom.Node node,
java.lang.String siblingName)
Search for the sibling node of a Node by name. |
static java.util.Vector |
getSiblingsByName(org.w3c.dom.Node node,
java.lang.String searchName,
java.lang.String stopName)
Search for all siblings of a Node by name. |
static org.w3c.dom.Document |
NewDoc()
Create a new instance of the Document interface. |
static javax.xml.transform.Transformer |
NewTrans()
Create an instance of the Transformer interface. |
static java.lang.String |
TransformNodeTree(org.w3c.dom.Node rootNode)
Transform a node tree to a String representation. |
static java.lang.String |
TransformOCEANDoc(OCEANDoc doc)
Transform an OCEAN trade proposal document to a String representation. |
static java.io.File |
TransformOCEANDocToFile(OCEANDoc doc,
java.lang.String fName)
Transform an OCEAN trade proposal document to a file. |
static java.lang.String |
TransformXMLFile(java.lang.String xmlFileName)
Transform the contents of an XML file to a String |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public XMLutils()
| Method Detail |
public static org.w3c.dom.Document NewDoc()
Document interface.Documentpublic static org.w3c.dom.Document getDOMDoc(java.lang.String docContent)
Document interface by parsing the
String representation of an XML document.Document tree that results from parsing the Stringpublic static javax.xml.transform.Transformer NewTrans()
Transformer interface.Transformerpublic static final java.lang.String TransformXMLFile(java.lang.String xmlFileName)
StringxmlFileName - name of the file to transformString contents of the filepublic static final java.lang.String TransformNodeTree(org.w3c.dom.Node rootNode)
String representation.rootNode - root of the node tree to transformString contents of the node treepublic static final java.lang.String TransformOCEANDoc(OCEANDoc doc)
String representation.doc - the document to transformString content of the OCEAN document
public static final java.io.File TransformOCEANDocToFile(OCEANDoc doc,
java.lang.String fName)
doc - the document to transformfName - name of the file in which to save the XML content
public static final org.w3c.dom.Node getSiblingByName(org.w3c.dom.Node node,
java.lang.String siblingName)
Node by name.node - The node where the search begins.siblingName - name of the node to search forNode if found, null if no such sibling exists.
public static final org.w3c.dom.Node getChildByName(org.w3c.dom.Node node,
java.lang.String name)
Node by name.node - The node where the search beginsname - the name of the node to search forNode if found, null if no such child exists.
public static final java.util.Vector getChildrenByName(org.w3c.dom.Node node,
java.lang.String searchName)
Node by name.node - The node where the search beginssearchName - the name to search forVector containing the found Nodes. If none found,
the Vector is empty.
public static final java.util.Vector getSiblingsByName(org.w3c.dom.Node node,
java.lang.String searchName,
java.lang.String stopName)
Node by name.node - The node where the search beginssearchName - the name to search forVector containing the found Nodes. If none found,
the Vector is empty.public static final org.w3c.dom.Node getChildElement(org.w3c.dom.Node node)
Node that is an Element.null if none
exists.
public static final java.lang.String getAttrVal(org.w3c.dom.Node node,
java.lang.String val)
Node for an attribute value.node - the node to searchval - the name of the attribute for which a value is soughtpublic static final java.lang.String getNodeText(org.w3c.dom.Node node)
node - the Node for which the text value is sought
public static final org.w3c.dom.Node getChildByType(org.w3c.dom.Node n,
short code)
Node for the first child of a given typen - the node to searchcode - the code that indicates the Node type
public static final void attachTextToNode(org.w3c.dom.Node n,
org.w3c.dom.Document d,
java.lang.String name,
java.lang.String val)
n - the node to which the new node is attachedd - the document in which the node is createdname - the name of the new nodeval - the text value to set for the new node
public static final void attachText(org.w3c.dom.Node n,
org.w3c.dom.Document d,
java.lang.String text)
n - the node for which the text will be setd - the document in which these actions will occurtext - the text to assign to the node
public static final void attachAttrToNode(org.w3c.dom.Element e,
org.w3c.dom.Document d,
java.lang.String name,
java.lang.String val)
e - the element to which the attribute is attachedd - the document in which these action occurname - the name of the attribute to createval - the value of the attribute
public static final void attachElemToNode(org.w3c.dom.Node n,
org.w3c.dom.Document d,
java.lang.String name)
n - the node to which the element is attachedd - the document in which these actions occurname - the name of the new element
public static final org.w3c.dom.Element getAttachedElem(org.w3c.dom.Node n,
org.w3c.dom.Document d,
java.lang.String name)
n - the node to which the element is attachedd - the document in which these actions occurname - the name of the new element
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||