public class XMLHelper
extends java.lang.Object
Constructor and Description |
---|
XMLHelper() |
Modifier and Type | Method and Description |
---|---|
static void |
addElement(org.w3c.dom.Document document,
org.w3c.dom.Element father,
java.lang.String name,
java.lang.String attOneName,
java.lang.String attOneValue)
adds an Element with one attribut to a DOM-tree.
|
static void |
addElement(org.w3c.dom.Document document,
org.w3c.dom.Element father,
java.lang.String name,
java.lang.String attOneName,
java.lang.String attOneValue,
java.lang.String attTwoName,
java.lang.String attTwoValue)
adds an Element with two attributs to a DOM-tree.
|
static void |
applyXSL(java.io.File xmlFile,
java.io.File xslFile,
java.lang.String outputFilename)
Transforms an xml-file (xmlFilename) using an xsl-file (xslFilename) and
writes the output into file (outputFilename).
|
static org.w3c.dom.CDATASection |
createCDATA(org.w3c.dom.Document d,
java.lang.String text)
Creates a CDATA section node in an XML document
|
static org.w3c.dom.Comment |
createComment(org.w3c.dom.Document d,
java.lang.String text)
Creates an XML comment with the given text
|
static org.w3c.dom.Document |
createDocument()
Creates a new DOM document.
|
static org.w3c.dom.Element |
createElement(org.w3c.dom.Document d,
java.lang.String name)
Creates a DOM element node with the given name.
|
static org.w3c.dom.Element |
createElement(org.w3c.dom.Document d,
java.lang.String name,
java.lang.String value,
boolean isCDATA)
Creates a DOM element node with the given name and contents.
|
static org.w3c.dom.Element |
createElementLn(org.w3c.dom.Document d,
java.lang.String name,
java.lang.String value,
boolean isCDATA)
Creates a DOM element node with the given name and contents.
|
static org.w3c.dom.Text |
createText(org.w3c.dom.Document d,
java.lang.String text)
Creates a text node in an XML document
|
static org.w3c.dom.Text |
createTextLn(org.w3c.dom.Document d)
Creates a text node in an XML document representing a new line character
|
static org.w3c.dom.Text |
createTextLn(org.w3c.dom.Document d,
java.lang.String text)
Creates a text node in an XML document ended by a new line character
|
static void |
serializeDocument(org.w3c.dom.Document document,
java.io.Writer out)
Saves a DOM tree as XML file
|
static void |
writeNode(org.w3c.dom.Node n,
java.io.FileOutputStream o)
Writes a DOM node (and all its ancestors) to the given output stream
|
public static void writeNode(org.w3c.dom.Node n, java.io.FileOutputStream o)
n
- the node to writeo
- the output stream to write the node topublic static org.w3c.dom.Element createElement(org.w3c.dom.Document d, java.lang.String name)
d
- the "mother" document of the created nodename
- the name of the nodepublic static org.w3c.dom.Comment createComment(org.w3c.dom.Document d, java.lang.String text)
d
- the "mother" document of the created commenttext
- the comment textpublic static org.w3c.dom.Text createText(org.w3c.dom.Document d, java.lang.String text)
d
- the "mother" document of the created text nodetext
- contents of the text nodepublic static org.w3c.dom.Element createElement(org.w3c.dom.Document d, java.lang.String name, java.lang.String value, boolean isCDATA)
d
- the "mother" document of the created Elementname
- the name of the elementvalue
- the element's valueisCDATA
- a flag indicating if this element contains (unformatted)
CDATA.public static org.w3c.dom.Element createElementLn(org.w3c.dom.Document d, java.lang.String name, java.lang.String value, boolean isCDATA)
d
- the "mother" document of the created Elementname
- the name of the elementvalue
- the element's valueisCDATA
- a flag indicating if this element contains (unformatted)
CDATA.public static org.w3c.dom.Text createTextLn(org.w3c.dom.Document d, java.lang.String text)
d
- the "mother" document of the created text nodetext
- contents of the text nodepublic static org.w3c.dom.Text createTextLn(org.w3c.dom.Document d)
d
- the "mother" document of the created text nodepublic static org.w3c.dom.CDATASection createCDATA(org.w3c.dom.Document d, java.lang.String text)
d
- the "mother" document of the created text nodetext
- the text this CDATA section containspublic static org.w3c.dom.Document createDocument()
public static void serializeDocument(org.w3c.dom.Document document, java.io.Writer out)
document
- Document: The DOM-Tree to be savedout:
- Writer: The (file)writer to be usedpublic static void addElement(org.w3c.dom.Document document, org.w3c.dom.Element father, java.lang.String name, java.lang.String attOneName, java.lang.String attOneValue)
document
- Document: the DOM-tree to add tofather
- Element: the new element will be inserted directly under this
Element in the treename
- String: the name of the new elementattOneName
- String: the name of the attributattOneValue
- String: the value of the attributpublic static void addElement(org.w3c.dom.Document document, org.w3c.dom.Element father, java.lang.String name, java.lang.String attOneName, java.lang.String attOneValue, java.lang.String attTwoName, java.lang.String attTwoValue)
document
- Document: the DOM-tree to add tofather
- Element: the new element will be inserted directly under this
Element in the treename
- String: the name of the new elementattOneName
- String: the name of the 1st attributattOneValue
- String: the value of the 1st attributattTwoName
- String: the name of the 2nd attributattTwoValue
- String: the value of the 2nd attributpublic static void applyXSL(java.io.File xmlFile, java.io.File xslFile, java.lang.String outputFilename)
xmlFile
- File: the xml-source-file to be transformedxslFile
- File: the xsl-file with the transformation rulesoutputFilename
- String: the name of the file the result will be written to