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 Schema |
createSchema(InputStream is)
Create schema object for the given xsd
|
static String |
escapeCharsForXML(String aText)
Escape characters for text appearing as XML data, between tags.
|
static String |
getRootAttribute(String filePath,
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(InputStream is)
Parse a inputstream assuming it is a valid XML document and return an JDOM Element for it.
|
static org.jdom.Element |
parseXml(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(String xmlStr)
Return a pretty print string for a XML string.
|
static String |
removeComments(String xmlStr)
Remove comments from any Xml String.
|
static void |
validateData(String xmlData,
SchemaService.SchemaName xsdFile) |
static void |
validateXml(Schema schema,
String xml)
Schema validation for a given xml.
|
static String |
writePropToString(Properties props)
Convert Properties to string
|
public XmlUtils()
public static String removeComments(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(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(InputStream is) throws org.jdom.JDOMException, IOException
is
- inputstream to parse.org.jdom.JDOMException
- thrown if an error happend while XML parsing.IOException
- thrown if an IO error occurred.public static String getRootAttribute(String filePath, 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(String xmlStr)
xmlStr
- XML string.public static XmlUtils.PrettyPrint prettyPrint(org.apache.hadoop.conf.Configuration conf)
conf
- Configuration object.public static void validateXml(Schema schema, String xml) throws SAXException, IOException
schema
- for validationxml
- to be validatedSAXException
- in case of validation errorIOException
- in case of IO errorpublic static Schema createSchema(InputStream is)
is
- inputstream to schema.public static void validateData(String xmlData, SchemaService.SchemaName xsdFile) throws SAXException, IOException
SAXException
IOException
public static String writePropToString(Properties props) throws IOException
props
- the properties to convertIOException
- if there is an error during conversionpublic static String escapeCharsForXML(String aText)
The following characters are replaced with corresponding character entities : '<' to '<' '>' to '>' '&' to '&' '"' to '"' "'" to "'"
Note that JSTL's <c:out>
escapes the exact same set of characters as this method.
aText
- the text to escapepublic static org.jdom.Element getSLAElement(org.jdom.Element elem)
Copyright © 2018 Apache Software Foundation. All rights reserved.