|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||

java.lang.Objecttoolbox.parsers.DOMParser
public final class DOMParser
Parser class to parse and access XML documents
| Constructor Summary | |
|---|---|
DOMParser()
Default constructor. |
|
DOMParser(boolean nsAware)
Create a namespace aware parser. |
|
| Method Summary | |
|---|---|
java.lang.String |
concatTextNodes(org.w3c.dom.Node node)
Concatenates the contents of all text() nodes in the given Node. |
java.util.Properties |
docToProps(org.w3c.dom.Document doc)
Converts the contents of the given document into a java.util.Properties instance. |
java.util.Properties |
docToProps(org.w3c.dom.Document doc,
java.lang.String delim)
Converts the contents of the given document into a java.util.Properties instance using a customer delimiter. |
java.lang.String |
getAttrValue(org.w3c.dom.Node node,
java.lang.String attrName)
Returns the value of the named attribute in the given node. |
java.lang.String |
getAttrValue(java.lang.String elementName,
java.lang.String attrName,
org.w3c.dom.Document document)
Returns the value of the named attribute in the named element of the given document. |
java.lang.String |
getAttrValue(java.lang.String elementName,
java.lang.String attrName,
org.w3c.dom.Document document,
java.lang.String ns)
Returns the value of the named attribute in the named element of the given document. |
org.w3c.dom.Element |
getElement(java.lang.String name,
org.w3c.dom.Document doc)
Returns the element with the given name or null if it does not exist. |
org.w3c.dom.Element |
getElement(java.lang.String name,
org.w3c.dom.Document doc,
java.lang.String ns)
Returns the element with the given name or null if it does not exist. |
org.w3c.dom.Element |
getElement(java.lang.String elementName,
org.w3c.dom.Element element)
Returns the named element inside of the given element. |
org.w3c.dom.Element |
getElement(java.lang.String elementName,
org.w3c.dom.Element element,
java.lang.String ns)
Returns the named element inside of the given element. |
org.w3c.dom.NodeList |
getElements(java.lang.String childName,
org.w3c.dom.Element parent)
Returns the children with the given name inside the given parent. |
org.w3c.dom.NodeList |
getElements(java.lang.String childName,
org.w3c.dom.Element parent,
java.lang.String ns)
Returns the children with the given name inside the given parent. |
java.util.List |
getElementsByAttrValue(java.lang.String elementName,
java.lang.String attrName,
java.lang.String attrValue,
org.w3c.dom.Element parent)
Returns a List of nodes that have the same name and contains a named attribute with the same value. |
java.util.List |
getElementsByAttrValue(java.lang.String elementName,
java.lang.String attrName,
java.lang.String attrValue,
org.w3c.dom.Element parent,
java.lang.String ns)
Returns a List of nodes that have the same name and contains a named attribute with the same value. |
java.lang.String |
getNodeName(org.w3c.dom.Node node)
Returns the name of the given node. |
java.lang.String |
getTextNodeValue(org.w3c.dom.Node node)
Returns the value of the given text node. |
java.lang.String |
getTextNodeValue(java.lang.String name,
org.w3c.dom.Document doc)
Returns the value of the named text node. |
java.lang.String |
getTextNodeValue(java.lang.String name,
org.w3c.dom.Document doc,
java.lang.String ns)
Returns the value of the named text node. |
java.lang.String |
getTextNodeValue(java.lang.String name,
org.w3c.dom.Node parent)
Returns the value of the named text node within the given parent node. |
java.lang.String |
getTextNodeValue(java.lang.String name,
org.w3c.dom.Node parent,
java.lang.String ns)
Returns the value of the named text node within the given parent node. |
java.lang.String |
getXMLStr(org.w3c.dom.Node node)
Converts the given XML node to an XML string. |
java.util.Properties |
nodeToProps(org.w3c.dom.Node node)
Converts the contents of the given node into a java.util.Properties instance. |
java.util.Properties |
nodeToProps(org.w3c.dom.Node node,
java.lang.String delim)
Converts the contents of the given node into a java.util.Properties instance using a customer delimiter. |
org.w3c.dom.Document |
parse(java.io.File file)
Parses the file and returns a Document. |
org.w3c.dom.Document |
parse(java.io.InputStream is)
Parse an InputStream and return a document. |
org.w3c.dom.Document |
parse(java.lang.String xmlStr)
Parses an XML string and returns a Document. |
void |
setNodeValue(org.w3c.dom.Node node,
java.lang.String attrName,
java.lang.String attrValue)
Sets the value of a specific attribute inside the given node. |
void |
setNodeValue(java.lang.String attrName,
java.lang.String attrVal,
org.w3c.dom.Node node)
Sets the value of the named attribute within the given node. |
void |
setNodeValue(java.lang.String elementName,
java.lang.String nodeName,
java.lang.String nodeValue,
org.w3c.dom.Document document)
Sets the value of a specific attribute inside the named node of a specific DOM document. |
void |
setNodeValue(java.lang.String elementName,
java.lang.String nodeName,
java.lang.String nodeValue,
org.w3c.dom.Document document,
java.lang.String ns)
Sets the value of a specific attribute inside the named node of a specific DOM document. |
void |
setTextNodeValue(org.w3c.dom.Node node,
java.lang.String value)
Sets the value of a text node. |
void |
setTextNodeValue(java.lang.String name,
java.lang.String value,
org.w3c.dom.Document doc)
Sets the value of the named text node. |
void |
setTextNodeValue(java.lang.String name,
java.lang.String value,
org.w3c.dom.Document doc,
java.lang.String ns)
Sets the value of the named text node. |
void |
transform(java.io.InputStream xmlIn,
java.io.InputStream xslIn,
java.io.OutputStream out,
java.util.Properties props)
Simple method to perform an XSL transformation that writes the output to the given OutputStream. |
java.lang.String |
transform(java.lang.String xmlIn,
java.lang.String xslIn,
java.util.Properties props)
Simple method to perform an XSL transformation that returns a String instance containing the results. |
void |
transform(java.lang.String xmlIn,
java.lang.String xslIn,
java.lang.String out,
java.util.Properties props)
Simple method to perform an XSL transformation that writes the output to a named file. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DOMParser()
public DOMParser(boolean nsAware)
nsAware - boolean indicating that the parse methods
must be namespace aware.| Method Detail |
|---|
public org.w3c.dom.Document parse(java.io.InputStream is)
is - InputStream to parse.public org.w3c.dom.Document parse(java.lang.String xmlStr)
xmlStr - XML string to parse.public org.w3c.dom.Document parse(java.io.File file)
file - File to parse.
public org.w3c.dom.Element getElement(java.lang.String name,
org.w3c.dom.Document doc)
name - Element name.doc - XML document.
public org.w3c.dom.Element getElement(java.lang.String name,
org.w3c.dom.Document doc,
java.lang.String ns)
name - Element name.doc - XML document.ns - String containing the namespace uri.
public org.w3c.dom.Element getElement(java.lang.String elementName,
org.w3c.dom.Element element)
elementName - The element name.element - The given element in which to look for the named
element.
public org.w3c.dom.Element getElement(java.lang.String elementName,
org.w3c.dom.Element element,
java.lang.String ns)
elementName - The element name.element - The given element in which to look for the named
element.ns - String containing the namespace uri.
public org.w3c.dom.NodeList getElements(java.lang.String childName,
org.w3c.dom.Element parent)
childName - Name of child elements to return.parent - Parent element.
public org.w3c.dom.NodeList getElements(java.lang.String childName,
org.w3c.dom.Element parent,
java.lang.String ns)
childName - Name of child elements to return.parent - Parent element.ns - String containing the namespace uri.
public void setTextNodeValue(java.lang.String name,
java.lang.String value,
org.w3c.dom.Document doc)
name - Text node name.value - New text node value.doc - XML document.
public void setTextNodeValue(java.lang.String name,
java.lang.String value,
org.w3c.dom.Document doc,
java.lang.String ns)
name - Text node name.value - New text node value.doc - XML document.ns - String containing the namespace uri.
public java.lang.String getTextNodeValue(java.lang.String name,
org.w3c.dom.Document doc)
name - Text node name.doc - XML document.
public java.lang.String getTextNodeValue(java.lang.String name,
org.w3c.dom.Document doc,
java.lang.String ns)
name - Text node name.doc - XML document.ns - String containing the namespace uri.
public java.lang.String getTextNodeValue(org.w3c.dom.Node node)
node - Given text node.
public java.lang.String getTextNodeValue(java.lang.String name,
org.w3c.dom.Node parent)
name - Name of the text node.parent - Parent node.
public java.lang.String getTextNodeValue(java.lang.String name,
org.w3c.dom.Node parent,
java.lang.String ns)
name - Name of the text node.parent - Parent node.ns - String containing the namespace uri.
public void setNodeValue(java.lang.String attrName,
java.lang.String attrVal,
org.w3c.dom.Node node)
attrName - Name of attribute.attrVal - Attribute value.node - Given node.
public void setNodeValue(java.lang.String elementName,
java.lang.String nodeName,
java.lang.String nodeValue,
org.w3c.dom.Document document)
elementName - The name of the element.nodeName - The name of the node.nodeValue - The new node value.document - The DOM document.
public void setNodeValue(java.lang.String elementName,
java.lang.String nodeName,
java.lang.String nodeValue,
org.w3c.dom.Document document,
java.lang.String ns)
elementName - The name of the element.nodeName - The name of the node.nodeValue - The new node value.document - The DOM document.ns - String containing the namespace uri.
public void setNodeValue(org.w3c.dom.Node node,
java.lang.String attrName,
java.lang.String attrValue)
node - The given node.attrName - The attribute name.attrValue - The new attribute value.public java.lang.String getNodeName(org.w3c.dom.Node node)
node - The given node.
public java.lang.String getAttrValue(java.lang.String elementName,
java.lang.String attrName,
org.w3c.dom.Document document)
elementName - The element name.attrName - The attribute name.document - The given document.
public java.lang.String getAttrValue(java.lang.String elementName,
java.lang.String attrName,
org.w3c.dom.Document document,
java.lang.String ns)
elementName - The element name.attrName - The attribute name.document - The given document.ns - String containing the namespace uri.
public java.lang.String getAttrValue(org.w3c.dom.Node node,
java.lang.String attrName)
node - The given node.attrName - The attribute name.
public void setTextNodeValue(org.w3c.dom.Node node,
java.lang.String value)
node - The text node.value - The new value of the text node.
public java.util.List getElementsByAttrValue(java.lang.String elementName,
java.lang.String attrName,
java.lang.String attrValue,
org.w3c.dom.Element parent)
elementName - Name of the element to look for.attrName - Name of attribute.attrValue - Value of attribute.parent - Parent node of elementName.
public java.util.List getElementsByAttrValue(java.lang.String elementName,
java.lang.String attrName,
java.lang.String attrValue,
org.w3c.dom.Element parent,
java.lang.String ns)
elementName - Name of the element to look for.attrName - Name of attribute.attrValue - Value of attribute.parent - Parent node of elementName.ns - String containing the namespace uri.
public java.lang.String getXMLStr(org.w3c.dom.Node node)
node - Node to convert.public java.lang.String concatTextNodes(org.w3c.dom.Node node)
node - Root Node to start the concatenation from.
public void transform(java.io.InputStream xmlIn,
java.io.InputStream xslIn,
java.io.OutputStream out,
java.util.Properties props)
throws java.lang.Exception
xmlIn - InputStream containing the XML to transform.xslIn - InputStream containing the XSL transformation rules.out - OutputStream where result must be written.props - Properties instance containing stylesheet parameters.
java.lang.Exception - if the transformation cannot be performed.
public java.lang.String transform(java.lang.String xmlIn,
java.lang.String xslIn,
java.util.Properties props)
throws java.lang.Exception
xmlIn - String containing the path to a file containing the XML
to transformxslIn - String containing the path to a file containing the XSL
transformation rules.props - Properties instance containing stylesheet parameters.
java.lang.Exception - if the transformation cannot be performed.
public void transform(java.lang.String xmlIn,
java.lang.String xslIn,
java.lang.String out,
java.util.Properties props)
throws java.lang.Exception
xmlIn - String containing the path to a file containing the XML
to transformxslIn - String containing the path to a file containing the XSL
transformation rules.out - String containing the path to the output file.props - Properties instance containing stylesheet parameters.
java.lang.Exception - if the transformation cannot be performed.public java.util.Properties docToProps(org.w3c.dom.Document doc)
This method does not use attribute names as property names, only element names are used.
doc - Document to convert.
public java.util.Properties docToProps(org.w3c.dom.Document doc,
java.lang.String delim)
This method does not use attribute names as property names, only element names are used.
doc - Document to convert.delim - String containing the property delimiter.
public java.util.Properties nodeToProps(org.w3c.dom.Node node)
This method does not use attribute names as property names, only element names are used.
node - Node to convert.
public java.util.Properties nodeToProps(org.w3c.dom.Node node,
java.lang.String delim)
This method does not use attribute names as property names, only element names are used.
node - Node to convert.delim - String containing the property delimiter.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||