|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.backsource.utils.xml.DocumentUtil
Util to handle stuff relating to documents and nodes.
| Constructor Summary | |
DocumentUtil()
|
|
| Method Summary | |
static org.w3c.dom.Node |
copyInto(org.w3c.dom.Node fromNode,
org.w3c.dom.Node toNode)
Copy the child nodes and its children from fromNode into toNode. |
static org.w3c.dom.Document |
createDocument(org.w3c.dom.Node node)
Create a new Document from the node, where node becomes the new root node and all its children the rest of the document. |
static org.w3c.dom.Document |
getDocument(java.io.File file)
If reading from a file, use this, since it will set the SystemId. |
static org.w3c.dom.Document |
getDocument(org.xml.sax.InputSource is)
FIXME: Here we could fix our own factory/prop stuff to use alternative builders than system default. |
static org.w3c.dom.Document |
getDocument(java.io.InputStream stream)
|
static org.w3c.dom.Document |
getDocument(java.io.Reader reader)
|
static org.w3c.dom.Document |
getDocument(java.lang.String xml)
Get DOM document from xml string- |
static org.w3c.dom.Element |
getDocumentElement(java.lang.String xml)
Create a DOM from string and return its root element. |
static org.w3c.dom.DocumentFragment |
getDocumentFragment(org.w3c.dom.Node node)
Create a document fragment around the node and its children, which are cloned. |
static org.w3c.dom.DocumentFragment |
getDocumentFragment(java.lang.String xml,
boolean forceElementTree)
Create a DocumentFragment from the XML given i string. |
static java.lang.String |
getXml(org.w3c.dom.Node node)
Get the serialized XML from node. |
static java.lang.String |
getXml(org.w3c.dom.Node node,
boolean indent,
java.lang.String encoding,
boolean omitDecl)
Return the string XML rep of node. |
static org.w3c.dom.Node |
importNode(org.w3c.dom.Document document,
org.w3c.dom.Node toImport)
Import node into document, make shure deep works (manually). |
static void |
main(java.lang.String[] args)
|
static void |
replace(org.w3c.dom.Node oldNode,
org.w3c.dom.Node newNode)
Replace oldNode with newNode and its children, importing the new node if needed. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public DocumentUtil()
| Method Detail |
public static java.lang.String getXml(org.w3c.dom.Node node)
throws XmlException
Get the serialized XML from node.
XmlException
public static java.lang.String getXml(org.w3c.dom.Node node,
boolean indent,
java.lang.String encoding,
boolean omitDecl)
throws XmlException
node - the node to serialize.indent - indent output if true.encoding - the encoding to use, if null iso-8859-1omitDecl - if true the xml prolog is omitted, which may be handly if the XML is to be used as a fragment.
XmlException
public static void replace(org.w3c.dom.Node oldNode,
org.w3c.dom.Node newNode)
throws XmlException
XmlException
public static org.w3c.dom.DocumentFragment getDocumentFragment(java.lang.String xml,
boolean forceElementTree)
throws XmlException
Create a DocumentFragment from the XML given i string.
The fragment may not be wellformed XML and may contain multiple children without a root node. To only allow a document fragment to returned where all the children are elements turn forceElementTree on. Any whitespace - including new line - will be removed before trying.
xml - the string possibly containing and XML fragment. The string is trimed before conversion.forceElementTree - the fragment is only valid if alla its children are elements, othervise an exception will be raised.
XMLException - if the xml string was not possible to convert to a document fragment or if null.
XmlException
public static org.w3c.dom.DocumentFragment getDocumentFragment(org.w3c.dom.Node node)
throws XmlException
XmlException
public static org.w3c.dom.Node copyInto(org.w3c.dom.Node fromNode,
org.w3c.dom.Node toNode)
public static org.w3c.dom.Node importNode(org.w3c.dom.Document document,
org.w3c.dom.Node toImport)
public static org.w3c.dom.Document createDocument(org.w3c.dom.Node node)
throws XmlException
XmlException
public static org.w3c.dom.Element getDocumentElement(java.lang.String xml)
throws XmlException
XmlException
public static org.w3c.dom.Document getDocument(java.lang.String xml)
throws XmlException
XmlException
public static org.w3c.dom.Document getDocument(java.io.File file)
throws XmlException
XmlException
public static org.w3c.dom.Document getDocument(java.io.Reader reader)
throws XmlException
XmlException
public static org.w3c.dom.Document getDocument(java.io.InputStream stream)
throws XmlException
XmlException
public static org.w3c.dom.Document getDocument(org.xml.sax.InputSource is)
throws XmlException
XmlExceptionpublic static void main(java.lang.String[] args)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||