|
Last update: 2011-06-23 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.proteios.util.XMLUtil
public class XMLUtil
This class contains some useful methods for handling XML documents.
| Constructor Summary | |
|---|---|
XMLUtil()
|
|
| Method Summary | |
|---|---|
static org.dom4j.Document |
createDom(String rootElement,
String systemId)
Create a new Document with root element and System id
declaration. |
static boolean |
getBooleanAttribute(org.dom4j.Element el,
String attribute,
boolean defaultValue)
Get the value of an attribute as a boolean. |
static int |
getIntAttribute(org.dom4j.Element el,
String attribute,
int defaultValue)
Get the value of an attribute as an integer. |
static org.dom4j.Document |
getValidatedXml(String xml,
URL dtdFile)
Parse and validate a string containing XML against a DTD, and return it as a Document object. |
static org.dom4j.Document |
getValidatedXml(URL xmlFile,
URL dtdFile)
Load and validate an XML file against a DTD, and return it as a Document object. |
static String |
toXml(org.dom4j.Document dom)
Convert a Document to xml. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public XMLUtil()
| Method Detail |
|---|
public static String toXml(org.dom4j.Document dom)
Document to xml. The encoding is set to UTF-8.
dom - The document
public static org.dom4j.Document createDom(String rootElement,
String systemId)
Document with root element and System id
declaration.
rootElement - The name of the root element tagsystemId - The system id in the DOCTYPE section
public static org.dom4j.Document getValidatedXml(URL xmlFile,
URL dtdFile)
throws org.dom4j.DocumentException,
IOException
Document object. The path to the files should
be given as a URL, not a filesystem path. For a file on the classpath
it is easiest done by the Class.getResource(String) method, ie.
XMLUtil.class.getResource("/org.proteios/core/the-xml-file.xml").
xmlFile - The URL to the XML filedtdFile - The URL to the DTD used for validation
Document object
org.dom4j.DocumentException
IOException
public static org.dom4j.Document getValidatedXml(String xml,
URL dtdFile)
throws org.dom4j.DocumentException,
IOException
Document object. The path to the DTD should
be given as a URL, not a filesystem path. For a file on the classpath
it is easiest done by the Class.getResource(String) method, ie.
XMLUtil.class.getResource("/org.proteios/core/the-dtd-file.dtd").
xml - The string containing the XMLdtdFile - The URL to the DTD used for validation
Document object
org.dom4j.DocumentException
IOException
public static int getIntAttribute(org.dom4j.Element el,
String attribute,
int defaultValue)
el - The node element which contains the attributeattribute - The name of the attributedefaultValue - The default value to return
public static boolean getBooleanAttribute(org.dom4j.Element el,
String attribute,
boolean defaultValue)
el - The node element which contains the attributeattribute - The name of the attributedefaultValue - The default value to return
|
Last update: 2011-06-23 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||