|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.apl.jxc.XMLUtil
public final class XMLUtil
XML handling utilities and helper methods.
Method Summary | |
---|---|
static void |
duplicateFirstElementByName(org.w3c.dom.Document doc,
java.lang.String elementName)
Modifies the document by adding a copy of the first node identified by element name. |
static void |
duplicateNthElementByName(org.w3c.dom.Document doc,
java.lang.String elementName,
int nodeIndex)
Modifies the document by adding a copy of the nth node identified by element name. |
static java.lang.String |
firstXPathFunctionParameterValue(java.lang.String xPathFunctionStr)
Returns the first parameter value from an XPath function call. |
static java.lang.String |
getElementNameFromPath(java.lang.String path)
Returns the element name from an XPath String. |
static boolean |
isDocumentValid(org.w3c.dom.Document doc,
java.io.File schemaFile)
Determines an XML document validates against a specified schema. |
static java.util.List<java.lang.String[]> |
parseXPathExpression(java.lang.String xPathExpression)
Parses an XPath expression into a list of its constituent parts. |
static org.w3c.dom.Document |
toXMLDocument(java.io.File xmlFile)
Returns an XML Document read from an XML file. |
static org.w3c.dom.Document |
toXMLDocument(java.io.File xmlFile,
boolean namespaceAware)
Returns a Document formed from an XML file. |
static org.w3c.dom.Document |
toXMLDocument(java.lang.String xmlString)
Returns a Document formed from an XML String. |
static org.w3c.dom.Document |
toXMLDocument(java.lang.String xmlString,
boolean namespaceAware)
Returns a Document formed from an XML String. |
static java.lang.String |
toXMLString(java.io.File xmlFile)
Returns a String representation of an XML files content. |
static java.lang.String |
toXMLString(org.w3c.dom.Node node)
Returns a String representation of an XML Node. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static java.lang.String toXMLString(java.io.File xmlFile) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException, javax.xml.transform.TransformerConfigurationException, javax.xml.transform.TransformerException
xmlFile
- the XML file
javax.xml.parsers.ParserConfigurationException
- when an exception occurs configuring the parser
org.xml.sax.SAXException
- when an exception occurs parsing the XML file
java.io.IOException
- when an exception occurs reading the XML file
javax.xml.transform.TransformerConfigurationException
- when an exception occurs configuring the transformet
javax.xml.transform.TransformerException
- when an exception occurs during transformationpublic static java.lang.String toXMLString(org.w3c.dom.Node node) throws javax.xml.transform.TransformerConfigurationException, javax.xml.transform.TransformerException
node
- the XML Node
javax.xml.transform.TransformerConfigurationException
- when an exception occurs configuring the transformet
javax.xml.transform.TransformerException
- when an exception occurs during transformationpublic static org.w3c.dom.Document toXMLDocument(java.io.File xmlFile) throws java.io.IOException, javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException
xmlFile
- the XML file to read
java.io.IOException
- when an exception occurs reading the XML file
javax.xml.transform.TransformerConfigurationException
- when an exception occurs configuring the transformet
javax.xml.transform.TransformerException
- when an exception occurs during transformation
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
public static org.w3c.dom.Document toXMLDocument(java.io.File xmlFile, boolean namespaceAware) throws java.io.IOException, javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException
xmlFile
- the XML filenamespaceAware
- true if the document should be namespace aware
java.io.IOException
- when an exception occurs reading the XML file
javax.xml.transform.TransformerConfigurationException
- when an exception occurs configuring the transformet
javax.xml.transform.TransformerException
- when an exception occurs during transformation
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
public static org.w3c.dom.Document toXMLDocument(java.lang.String xmlString) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
xmlString
- the XML String
javax.xml.parsers.ParserConfigurationException
- when an exception occurs configuring the parser
org.xml.sax.SAXException
- when an exception occurs parsing the XML file
java.io.IOException
- when an exception occurs reading the XML filepublic static org.w3c.dom.Document toXMLDocument(java.lang.String xmlString, boolean namespaceAware) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
xmlString
- the XML StringnamespaceAware
- true if the document should be namespace aware
javax.xml.parsers.ParserConfigurationException
- when an exception occurs configuring the parser
org.xml.sax.SAXException
- when an exception occurs parsing the XML file
java.io.IOException
- when an exception occurs reading the XML filepublic static java.lang.String getElementNameFromPath(java.lang.String path)
path
- the XPath String
public static boolean isDocumentValid(org.w3c.dom.Document doc, java.io.File schemaFile) throws java.io.IOException
doc
- the document to be validatedschemaFile
- the XSD to validate the document against
java.io.IOException
- if the schema cannot be loadedpublic static void duplicateFirstElementByName(org.w3c.dom.Document doc, java.lang.String elementName)
doc
- the document to be modifiedelementName
- name of the element to be duplicatedpublic static void duplicateNthElementByName(org.w3c.dom.Document doc, java.lang.String elementName, int nodeIndex)
doc
- the document to be modifiedelementName
- name of the element to be duplicatednodeIndex
- occurence of the element to be duplicatedpublic static java.lang.String firstXPathFunctionParameterValue(java.lang.String xPathFunctionStr)
contains(elementName, 'blah')
would
return elementName.
xPathFunctionStr
- string representation of an XPath function call
public static java.util.List<java.lang.String[]> parseXPathExpression(java.lang.String xPathExpression)
contains(element1, 'blah') = true() and element2 > 1 or element3 < number('23')
List Index | Array Index | Contents |
0 | 0 | |
0 | 1 | contains(element1, 'blah') |
0 | 2 | = |
0 | 3 | true() |
1 | 0 | and |
1 | 1 | element2 |
1 | 2 | > |
1 | 3 | 1 |
2 | 0 | or |
2 | 1 | element3 |
2 | 2 | < |
2 | 3 | number('23') |
xPathExpression
- the XPath expression to be parsed
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |