org.ow2.orchestra.util
Class XmlUtil
java.lang.Object
org.ow2.orchestra.util.XmlUtil
public abstract class XmlUtil
- extends Object
convenience methods to make reading org.w3c.dom models easier.
- Author:
- Tom Baeyens
|
Method Summary |
static String |
attribute(Element element,
String attributeName)
the attribute value or null if the attribute is not present |
static XmlUtil.NamespaceValue |
attributeNamespaceValue(Element element,
String attributeName)
|
static QName |
attributeQName(Element element,
String attributeName)
|
static List<Attr> |
attributes(Element element)
|
static Element |
element(Element element)
|
static Element |
element(Element element,
String tagName)
|
static Element |
element(Element element,
String ns,
String localName)
|
static List<Element> |
elements(Element element)
|
static List<Element> |
elements(Element element,
Set<String> allowedTagNames)
|
static List<Element> |
elements(Element element,
String tagName)
|
static List<Element> |
elements(Element father,
String ns,
String localName)
|
static List<Element> |
elementsQName(Element element,
Set<QName> allowedTagNames)
|
static String |
errorMessageAttribute(Element element,
String attributeName,
String attributeValue,
String message)
|
static String |
getContentText(Element element)
|
protected static DocumentBuilder |
getDocumentBuilder()
|
static Document |
getDocumentFromFile(File xmlFile)
|
static Document |
getDocumentFromInputStream(InputStream is)
|
static Document |
getDocumentFromReader(Reader r)
|
static Document |
getDocumentFromString(String s)
|
static Document |
getDocumentFromString(String s,
boolean createProxy)
|
static Document |
getDocumentFromURL(URL xmlUrl)
|
static Element |
getDocumentWithOneElement(QName elementQName)
|
static String |
getNamespaceURI(Node n,
String prefix)
|
static Document |
getNewDocument()
|
static ByteArrayOutputStream |
getNodeAsBAOS(Node n)
|
static QName |
getQNameFromString(Element element,
String qnameAsString)
|
static String |
getTagLocalName(Element element)
|
static TransformerFactory |
getTransformerFactory()
|
static boolean |
isTextOnly(Element element)
|
static Boolean |
parseBooleanValue(String valueText)
|
static List<String> |
parseCommaSeparatedList(String commaSeparatedListText)
parses comma or space separated list. |
static List<String> |
parseList(Element element,
String singularTagName)
|
static String |
toString(Node node)
|
static void |
writeXmlFile(Document doc,
File file)
This method writes a DOM document to a file. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
elements
public static List<Element> elements(Element element,
String tagName)
elements
public static List<Element> elements(Element element,
Set<String> allowedTagNames)
element
public static Element element(Element element,
String tagName)
element
public static Element element(Element element,
String ns,
String localName)
elements
public static List<Element> elements(Element element)
elements
public static List<Element> elements(Element father,
String ns,
String localName)
elementsQName
public static List<Element> elementsQName(Element element,
Set<QName> allowedTagNames)
element
public static Element element(Element element)
toString
public static String toString(Node node)
getContentText
public static String getContentText(Element element)
isTextOnly
public static boolean isTextOnly(Element element)
attributes
public static List<Attr> attributes(Element element)
getTagLocalName
public static String getTagLocalName(Element element)
attribute
public static String attribute(Element element,
String attributeName)
- the attribute value or null if the attribute is not present
parseBooleanValue
public static Boolean parseBooleanValue(String valueText)
errorMessageAttribute
public static String errorMessageAttribute(Element element,
String attributeName,
String attributeValue,
String message)
parseList
public static List<String> parseList(Element element,
String singularTagName)
parseCommaSeparatedList
public static List<String> parseCommaSeparatedList(String commaSeparatedListText)
- parses comma or space separated list. A null return value means a wildcard.
- Returns:
- List of tokens or null if the commaSeparatedListText is null, '*',
or empty
attributeNamespaceValue
public static XmlUtil.NamespaceValue attributeNamespaceValue(Element element,
String attributeName)
attributeQName
public static QName attributeQName(Element element,
String attributeName)
getTransformerFactory
public static TransformerFactory getTransformerFactory()
getQNameFromString
public static QName getQNameFromString(Element element,
String qnameAsString)
getNamespaceURI
public static String getNamespaceURI(Node n,
String prefix)
getDocumentBuilder
protected static DocumentBuilder getDocumentBuilder()
getNewDocument
public static Document getNewDocument()
writeXmlFile
public static void writeXmlFile(Document doc,
File file)
- This method writes a DOM document to a file.
- Parameters:
doc - - doc to writefile - - dest file;
getNodeAsBAOS
public static ByteArrayOutputStream getNodeAsBAOS(Node n)
getDocumentFromString
public static Document getDocumentFromString(String s)
getDocumentFromString
public static Document getDocumentFromString(String s,
boolean createProxy)
getDocumentFromInputStream
public static Document getDocumentFromInputStream(InputStream is)
getDocumentFromReader
public static Document getDocumentFromReader(Reader r)
getDocumentFromFile
public static Document getDocumentFromFile(File xmlFile)
getDocumentFromURL
public static Document getDocumentFromURL(URL xmlUrl)
getDocumentWithOneElement
public static Element getDocumentWithOneElement(QName elementQName)
Copyright © 2011 OW2 Consortium. All Rights Reserved.