public class XMLHandler extends Object
| Constructor and Description |
|---|
XMLHandler() |
| Modifier and Type | Method and Description |
|---|---|
static String |
addTagValue(KettleAttributeInterface tag,
boolean bool)
Build an XML string (including a carriage return) for a certain tag boolean value
|
static String |
addTagValue(KettleAttributeInterface tag,
int i)
Build an XML string (with carriage return) for a certain tag integer value
|
static String |
addTagValue(KettleAttributeInterface tag,
String val)
Build an XML string (including a carriage return) for a certain tag String value
|
static String |
addTagValue(String tag,
BigDecimal val)
Build an XML string (including a carriage return) for a certain tag BigDecimal value
|
static String |
addTagValue(String tag,
BigDecimal val,
boolean cr)
Build an XML string (including a carriage return) for a certain tag BigDecimal value
|
static String |
addTagValue(String tag,
boolean bool)
Build an XML string (including a carriage return) for a certain tag boolean value
|
static String |
addTagValue(String tag,
boolean bool,
boolean cr)
Build an XML string for a certain tag boolean value
|
static String |
addTagValue(String tag,
byte[] val)
Build an XML string (including a carriage return) for a certain tag binary (byte[]) value
|
static String |
addTagValue(String tag,
byte[] val,
boolean cr)
Build an XML string (including a carriage return) for a certain tag binary (byte[]) value
|
static String |
addTagValue(String tag,
Date date)
Build an XML string (with carriage return) for a certain tag Date value
|
static String |
addTagValue(String tag,
Date date,
boolean cr)
Build an XML string for a certain tag Date value
|
static String |
addTagValue(String tag,
double d)
Build an XML string (with carriage return) for a certain tag double value
|
static String |
addTagValue(String tag,
double d,
boolean cr)
Build an XML string for a certain tag double value
|
static String |
addTagValue(String tag,
int i)
Build an XML string (with carriage return) for a certain tag integer value
|
static String |
addTagValue(String tag,
int i,
boolean cr)
Build an XML string for a certain tag integer value
|
static String |
addTagValue(String tag,
long l)
Build an XML string for a certain tag long integer value
|
static String |
addTagValue(String tag,
long l,
boolean cr)
Build an XML string for a certain tag long integer value
|
static String |
addTagValue(String tag,
String val)
Build an XML string (including a carriage return) for a certain tag String value
|
static String |
addTagValue(String tag,
String val,
boolean cr,
String... attributes)
Build an XML string for a certain tag String value
|
static void |
appendReplacedChars(StringBuffer value,
String string)
Take the characters from string val and append them to the value stringbuffer
In case a character is not allowed in XML, we convert it to an XML code
|
static String |
buildCDATA(String string) |
static String |
closeTag(String tag) |
static int |
countNodes(Node n,
String tag)
Count nodes with a certain tag
|
static String |
date2string(Date date) |
static String |
encodeBinaryData(byte[] val) |
static String |
formatNode(Node node) |
static String[] |
getNodeAttributes(Node node)
Get all the attributes in a certain node (on the root level)
|
static String[] |
getNodeElements(Node node) |
static List<Node> |
getNodes(Node n,
String tag)
Get nodes with a certain tag one level down
|
static String |
getNodeValue(Node n)
Find the value entry in a node
|
static Node |
getNodeWithAttributeValue(Node n,
String tag,
String attributeName,
String attributeValue)
Get node child with a certain subtag set to a certain value
|
static Node |
getNodeWithTagValue(Node n,
String tag,
String subtag,
String subtagvalue,
int nr)
Get node child with a certain subtag set to a certain value
|
static String |
getString() |
static Node |
getSubNode(Node n,
String tag)
Search for a subnode in the node with a certain tag.
|
static Node |
getSubNode(Node n,
String tag,
String subtag)
Search a node for a child of child
|
static Node |
getSubNodeByNr(Node n,
String tag,
int nr)
Get a subnode in a node by nr.
This method uses caching and assumes you loop over subnodes in sequential order (nr is increasing by 1 each call) |
static Node |
getSubNodeByNr(Node n,
String tag,
int nr,
boolean useCache)
Get a subnode in a node by nr.
It optially allows you to use caching. Caching assumes that you loop over subnodes in sequential order (nr is increasing by 1 each call) |
static String |
getTagAttribute(Node node,
String attribute) |
static String |
getTagValue(Node n,
KettleAttributeInterface code)
Get the value of a tag in a node
|
static String |
getTagValue(Node n,
String tag)
Get the value of a tag in a node
|
static String |
getTagValue(Node n,
String tag,
String subtag)
Search a node for a certain tag, in that subnode search for a certain subtag.
|
static String |
getTagValueWithAttribute(Node n,
String tag,
String attribute)
Get the value of a tag in a node
|
static String |
getXMLHeader()
The header string to specify encoding in UTF-8 for XML files
|
static String |
getXMLHeader(String encoding)
The header string to specify encoding in an XML file
|
static Document |
loadXMLFile(File resource) |
static Document |
loadXMLFile(org.apache.commons.vfs.FileObject fileObject)
Load a file into an XML document
|
static Document |
loadXMLFile(org.apache.commons.vfs.FileObject fileObject,
String systemID,
boolean ignoreEntities,
boolean namespaceAware)
Load a file into an XML document
|
static Document |
loadXMLFile(InputStream inputStream)
Read in an XML file from the passed input stream and return an XML document
|
static Document |
loadXMLFile(InputStream inputStream,
String systemID,
boolean ignoreEntities,
boolean namespaceAware)
Load a file into an XML document
|
static Document |
loadXMLFile(String filename)
Load a file into an XML document
|
static Document |
loadXMLFile(URL resource)
Load a file into an XML document
|
static Document |
loadXMLString(String string)
Calls loadXMLString with deferNodeExpansion = TRUE
|
static Document |
loadXMLString(String string,
Boolean namespaceAware,
Boolean deferNodeExpansion)
Load a String into an XML document
|
static Node |
loadXMLString(String xml,
String tag)
Loads the XML document in parameter xml and returns the 'tag' entry.
|
static String |
openTag(String tag) |
static byte[] |
stringToBinary(String string)
Convert a XML encoded binary string back to binary format
|
static Date |
stringToDate(String dateString) |
public static final String getXMLHeader()
public static final String getXMLHeader(String encoding)
encoding - The desired encoding to use in the XML filepublic static final String getTagValue(Node n, KettleAttributeInterface code)
n - The node to look intag - The tag to look forpublic static final String getTagValue(Node n, String tag)
n - The node to look intag - The tag to look forpublic static final String getTagValueWithAttribute(Node n, String tag, String attribute)
n - The node to look intag - The tag to look forpublic static final String getTagValue(Node n, String tag, String subtag)
n - The node to look intag - The tag to look forsubtag - The subtag to look forpublic static final int countNodes(Node n, String tag)
n - The node to look intag - The tags to countpublic static final List<Node> getNodes(Node n, String tag)
n - The node to look intag - The tags to countpublic static final Node getNodeWithTagValue(Node n, String tag, String subtag, String subtagvalue, int nr)
n - The node to search intag - The tag to look forsubtag - The subtag to look forsubtagvalue - The value the subtag should havenr - The nr of occurance of the valuepublic static final Node getNodeWithAttributeValue(Node n, String tag, String attributeName, String attributeValue)
n - The node to search intag - The tag to look forsubtag - The subtag to look forsubtagvalue - The value the subtag should havecopyNr - The nr of occurance of the valuepublic static final Node getSubNode(Node n, String tag)
n - The node to look intag - The tag to look forpublic static final Node getSubNode(Node n, String tag, String subtag)
n - The node to look intag - The tag to look for in the nodesubtag - The tag to look for in the children of the nodepublic static final Node getSubNodeByNr(Node n, String tag, int nr)
n - The node to look intag - The tag to countnr - The position in the nodepublic static final Node getSubNodeByNr(Node n, String tag, int nr, boolean useCache)
n - The node to look intag - The tag to countnr - The position in the nodeuseCache - set this to false if you don't want to use caching. For example in cases where you want to loop over subnodes of a certain tag in reverse or random order.public static final String getNodeValue(Node n)
n - The nodepublic static final Document loadXMLFile(String filename) throws KettleXMLException
filename - The filename to load into a documentKettleXMLExceptionpublic static final Document loadXMLFile(org.apache.commons.vfs.FileObject fileObject) throws KettleXMLException
filename - The filename to load into a documentKettleXMLExceptionpublic static final Document loadXMLFile(org.apache.commons.vfs.FileObject fileObject, String systemID, boolean ignoreEntities, boolean namespaceAware) throws KettleXMLException
filename - The filename to load into a documentsystemId - Provide a base for resolving relative URIs.ignoreEntities - Ignores external entities and returns an empty dummy.namespaceAware - support XML namespaces.KettleXMLExceptionpublic static final Document loadXMLFile(InputStream inputStream) throws KettleXMLException
inputStream - The filename input stream to read the document fromKettleXMLExceptionpublic static final Document loadXMLFile(InputStream inputStream, String systemID, boolean ignoreEntities, boolean namespaceAware) throws KettleXMLException
inputStream - The stream to load a document fromsystemId - Provide a base for resolving relative URIs.ignoreEntities - Ignores external entities and returns an empty dummy.namespaceAware - support XML namespaces.KettleXMLExceptionpublic static final Document loadXMLFile(File resource) throws KettleXMLException
KettleXMLExceptionpublic static final Document loadXMLFile(URL resource) throws KettleXMLException
file - The file to load into a documentKettleXMLExceptionpublic static final Document loadXMLString(String string) throws KettleXMLException
string - KettleXMLExceptionpublic static final Node loadXMLString(String xml, String tag) throws KettleXMLException
xml - the XML to loadtag - the node to returnKettleXMLException - in case there is a problem reading the XMLpublic static final Document loadXMLString(String string, Boolean namespaceAware, Boolean deferNodeExpansion) throws KettleXMLException
string - The XML text to load into a documentBoolean - true to defer node expansion, false to not defer.KettleXMLExceptionpublic static final String getString()
public static final String addTagValue(String tag, String val, boolean cr, String... attributes)
tag - The XML tagval - The String value of the tagcr - true if a carriage return is desired after the ending tag.public static void appendReplacedChars(StringBuffer value, String string)
value - the stringbuffer to append tostring - the string to "encode"public static final String addTagValue(KettleAttributeInterface tag, String val)
tag - The XML tagval - The String value of the tagpublic static final String addTagValue(String tag, String val)
tag - The XML tagval - The String value of the tagpublic static final String addTagValue(KettleAttributeInterface tag, boolean bool)
tag - The XML tagbool - The boolean value of the tagpublic static final String addTagValue(String tag, boolean bool)
tag - The XML tagbool - The boolean value of the tagpublic static final String addTagValue(String tag, boolean bool, boolean cr)
tag - The XML tagbool - The boolean value of the tagcr - true if a carriage return is desired after the ending tag.public static final String addTagValue(String tag, long l)
tag - The XML tagl - The long integer value of the tagpublic static final String addTagValue(String tag, long l, boolean cr)
tag - The XML tagl - The long integer value of the tagcr - true if a carriage return is desired after the ending tag.public static final String addTagValue(KettleAttributeInterface tag, int i)
tag - The XML tagi - The integer value of the tagpublic static final String addTagValue(String tag, int i)
tag - The XML tagi - The integer value of the tagpublic static final String addTagValue(String tag, int i, boolean cr)
tag - The XML tagi - The integer value of the tagcr - true if a carriage return is desired after the ending tag.public static final String addTagValue(String tag, double d)
tag - The XML tagd - The double value of the tagpublic static final String addTagValue(String tag, double d, boolean cr)
tag - The XML tagd - The double value of the tagcr - true if a carriage return is desired after the ending tag.public static final String addTagValue(String tag, Date date)
tag - The XML tagdate - The Date value of the tagpublic static final String addTagValue(String tag, Date date, boolean cr)
tag - The XML tagdate - The Date value of the tagcr - true if a carriage return is desired after the ending tag.public static final String addTagValue(String tag, BigDecimal val)
tag - The XML tagval - The BigDecimal value of the tagpublic static final String addTagValue(String tag, BigDecimal val, boolean cr)
tag - The XML tagval - The BigDecimal value of the tagpublic static final String addTagValue(String tag, byte[] val) throws IOException
tag - The XML tagval - The binary value of the tagIOException - in case there is an Base64 or GZip encoding problempublic static final String addTagValue(String tag, byte[] val, boolean cr) throws IOException
tag - The XML tagval - The binary value of the tagIOException - in case there is an Base64 or GZip encoding problempublic static String encodeBinaryData(byte[] val) throws IOException
IOExceptionpublic static String[] getNodeAttributes(Node node)
node - The node to examinepublic static byte[] stringToBinary(String string) throws KettleException
string - the (Byte64/GZip) encoded stringKettleException - In case there is a decoding errorpublic static String formatNode(Node node) throws KettleXMLException
KettleXMLException