public class XmlUtils extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
XmlUtils.PrettyPrint
Pretty print string representation of an XML document that generates the pretty print on lazy mode when the
XmlUtils.PrettyPrint.toString() method is invoked. |
| Constructor and Description |
|---|
XmlUtils() |
| Modifier and Type | Method and Description |
|---|---|
static javax.xml.validation.Schema |
createSchema(java.io.InputStream is)
Create schema object for the given xsd
|
static java.lang.String |
escapeCharsForXML(java.lang.String aText)
Escape characters for text appearing as XML data, between tags.
|
static java.lang.String |
getRootAttribute(java.lang.String filePath,
java.lang.String attributeName)
//TODO move this to action registry method Return the value of an attribute from the root element of an XML
document.
|
static org.jdom.Element |
getSLAElement(org.jdom.Element elem) |
static org.jdom.Element |
parseXml(java.io.InputStream is)
Parse a inputstream assuming it is a valid XML document and return an JDOM Element for it.
|
static org.jdom.Element |
parseXml(java.lang.String xmlStr)
Parse a string assuming it is a valid XML document and return an JDOM Element for it.
|
static XmlUtils.PrettyPrint |
prettyPrint(org.apache.hadoop.conf.Configuration conf)
Return a pretty print string for a Configuration object.
|
static XmlUtils.PrettyPrint |
prettyPrint(org.jdom.Element element)
Return a pretty print string for a JDOM Element.
|
static XmlUtils.PrettyPrint |
prettyPrint(java.lang.String xmlStr)
Return a pretty print string for a XML string.
|
static java.lang.String |
removeComments(java.lang.String xmlStr)
Remove comments from any Xml String.
|
static void |
validateData(java.lang.String xmlData,
SchemaService.SchemaName xsdFile) |
static void |
validateXml(javax.xml.validation.Schema schema,
java.lang.String xml)
Schema validation for a given xml.
|
static java.lang.String |
writePropToString(java.util.Properties props)
Convert Properties to string
|
public XmlUtils()
public static java.lang.String removeComments(java.lang.String xmlStr) throws org.jdom.JDOMException
xmlStr - XML string to remove comments.org.jdom.JDOMException - thrown if an error happend while XML parsing.public static org.jdom.Element parseXml(java.lang.String xmlStr) throws org.jdom.JDOMException
xmlStr - XML string to parse.org.jdom.JDOMException - thrown if an error happend while XML parsing.public static org.jdom.Element parseXml(java.io.InputStream is) throws org.jdom.JDOMException, java.io.IOException
is - inputstream to parse.org.jdom.JDOMException - thrown if an error happend while XML parsing.java.io.IOException - thrown if an IO error occurred.public static java.lang.String getRootAttribute(java.lang.String filePath, java.lang.String attributeName)
filePath - path of the XML document.attributeName - attribute to retrieve value for.public static XmlUtils.PrettyPrint prettyPrint(org.jdom.Element element)
element - JDOM element.public static XmlUtils.PrettyPrint prettyPrint(java.lang.String xmlStr)
xmlStr - XML string.public static XmlUtils.PrettyPrint prettyPrint(org.apache.hadoop.conf.Configuration conf)
conf - Configuration object.public static void validateXml(javax.xml.validation.Schema schema, java.lang.String xml) throws org.xml.sax.SAXException, java.io.IOException
schema - for validationxml - to be validatedorg.xml.sax.SAXExceptionjava.io.IOExceptionpublic static javax.xml.validation.Schema createSchema(java.io.InputStream is)
is - inputstream to schema.public static void validateData(java.lang.String xmlData, SchemaService.SchemaName xsdFile) throws org.xml.sax.SAXException, java.io.IOException
org.xml.sax.SAXExceptionjava.io.IOExceptionpublic static java.lang.String writePropToString(java.util.Properties props) throws java.io.IOException
props - java.io.IOExceptionpublic static java.lang.String escapeCharsForXML(java.lang.String aText)
<c:out> escapes the exact same set of characters as this method.public static org.jdom.Element getSLAElement(org.jdom.Element elem)
Copyright © 2017 Apache Software Foundation. All Rights Reserved.