public class XMLUtils extends Object
Modifier and Type | Class and Description |
---|---|
static class |
XMLUtils.ParserErrorHandler |
Modifier and Type | Field and Description |
---|---|
static String |
charEncoding |
Constructor and Description |
---|
XMLUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
base64encode(byte[] bytes) |
static Node |
findNode(Node node,
javax.xml.namespace.QName name)
Finds a Node with a given QNameb.
|
static String |
getChildCharacterData(Element parentEl)
Concatinates all the text and cdata node children of this elem and returns
the resulting text.
|
static InputSource |
getEmptyInputSource() |
static InputSource |
getInputSourceFromURI(String uri)
Utility to get the bytes uri.
|
static String |
getNamespace(String prefix,
Node e) |
static String |
getPrefix(String uri,
Node e) |
static javax.xml.namespace.QName |
getQNameFromString(String str,
Node e)
Returns a QName when passed a string like "foo:bar" by mapping
the "foo" prefix to a namespace in the context of the given Node.
|
static String |
getStringForQName(javax.xml.namespace.QName qname,
Element e)
Returns a string for a particular QName, mapping a new prefix
if necessary.
|
static void |
initSAXFactory(String factoryClassName,
boolean namespaceAware,
boolean validating)
Initializes the SAX parser factory.
|
static Document |
newDocument()
Gets an empty new Document.
|
static Document |
newDocument(InputSource inp)
Gets a new Document read from the input source.
|
static Document |
newDocument(InputStream inp)
Gets a new Document read from the input stream
|
static Document |
newDocument(String uri)
Gets a new Document read from the indicated uri
|
static Document |
newDocument(String uri,
String username,
String password)
Creates a new document from the given URI.
|
static void |
releaseSAXParser(SAXParser parser)
Returns a SAX parser for reuse.
|
static Element |
toDOM(org.apache.axiom.om.OMElement element)
Converts a given OMElement to a DOM Element.
|
static org.apache.axiom.om.OMElement |
toOM(Element element)
Convert DOM Element into a fully built OMElement
|
static org.apache.axiom.om.OMElement |
toOM(Element element,
boolean buildAll)
Convert DOM Element into a fully built OMElement
|
static org.apache.axiom.om.OMNode |
toOM(InputStream inputStream)
Converts a given inputstream to an OMNode
The reurned OMNode is fully built.
|
static org.apache.axiom.om.OMNode |
toOM(InputStream inputStream,
boolean buildAll)
Converts a given inputstream to an OMNode
The reurned OMNode is fully built if buildAll is true.
|
static org.apache.axiom.om.OMNode |
toOM(Reader reader)
Converts a given Reader to an OMNode.
|
static org.apache.axiom.om.OMNode |
toOM(Reader reader,
boolean buildAll)
Converts a given Reader to an OMNode.
|
public static final String charEncoding
public static void initSAXFactory(String factoryClassName, boolean namespaceAware, boolean validating)
factoryClassName
- The (optional) class name of the desired
SAXParserFactory implementation. Will be
assigned to the system property
javax.xml.parsers.SAXParserFactory
unless this property is already set.
If null
, leaves current setting
alone.namespaceAware
- true if we want a namespace-aware parservalidating
- true if we want a validating parserpublic static void releaseSAXParser(SAXParser parser)
parser
- A SAX parser that is available for reusepublic static Document newDocument() throws ParserConfigurationException
ParserConfigurationException
- if construction problems occurpublic static Document newDocument(InputSource inp) throws ParserConfigurationException, SAXException, IOException
ParserConfigurationException
- if construction problems occurSAXException
- if the document has xml sax problemsIOException
- if i/o exceptions occurpublic static Document newDocument(InputStream inp) throws ParserConfigurationException, SAXException, IOException
ParserConfigurationException
- if construction problems occurSAXException
- if the document has xml sax problemsIOException
- if i/o exceptions occurpublic static Document newDocument(String uri) throws ParserConfigurationException, SAXException, IOException
ParserConfigurationException
- if construction problems occurSAXException
- if the document has xml sax problemsIOException
- if i/o exceptions occurpublic static Document newDocument(String uri, String username, String password) throws ParserConfigurationException, SAXException, IOException
uri
- the resource to getusername
- basic auth usernamepassword
- basic auth passwordParserConfigurationException
- if construction problems occurSAXException
- if the document has xml sax problemsIOException
- if i/o exceptions occurpublic static javax.xml.namespace.QName getQNameFromString(String str, Node e)
public static String getStringForQName(javax.xml.namespace.QName qname, Element e)
public static String getChildCharacterData(Element parentEl)
parentEl
- the element whose cdata/text node values are to
be combined.public static InputSource getInputSourceFromURI(String uri)
uri
- the resource to getpublic static String base64encode(byte[] bytes)
public static InputSource getEmptyInputSource()
public static Node findNode(Node node, javax.xml.namespace.QName name)
node
- parent nodename
- QName of the child we need to findpublic static org.apache.axiom.om.OMElement toOM(Element element) throws Exception
element
- dom ElementException
public static org.apache.axiom.om.OMElement toOM(Element element, boolean buildAll) throws Exception
element
- buildAll
- if true, full OM tree is immediately built. if false, caller is responsible
for building the tree and closing the parser.Exception
public static Element toDOM(org.apache.axiom.om.OMElement element) throws Exception
element
- Exception
public static org.apache.axiom.om.OMNode toOM(InputStream inputStream) throws javax.xml.stream.XMLStreamException
inputStream
- javax.xml.stream.XMLStreamException
public static org.apache.axiom.om.OMNode toOM(InputStream inputStream, boolean buildAll) throws javax.xml.stream.XMLStreamException
inputStream
- buildAll
- javax.xml.stream.XMLStreamException
public static org.apache.axiom.om.OMNode toOM(Reader reader) throws javax.xml.stream.XMLStreamException
reader
- javax.xml.stream.XMLStreamException
public static org.apache.axiom.om.OMNode toOM(Reader reader, boolean buildAll) throws javax.xml.stream.XMLStreamException
reader
- buildAll
- javax.xml.stream.XMLStreamException
Copyright © 2004–2014 The Apache Software Foundation. All rights reserved.