org.apache.axis.utils
public class XMLUtils extends Object
Nested Class Summary | |
---|---|
static class | XMLUtils.ParserErrorHandler |
Field Summary | |
---|---|
protected static boolean | enableParserReuse |
static String | httpAuthCharEncoding |
protected static Log | log |
Method Summary | |
---|---|
static Element[] | asElementArray(List list)
Converts a List with org.w3c.dom.Element objects to an Array
with org.w3c.dom.Element objects. |
static String | base64encode(byte[] bytes) |
static void | DocumentToStream(Document doc, OutputStream out) |
static String | DocumentToString(Document doc)
turn a whole DOM document into XML |
static void | DocumentToWriter(Document doc, Writer writer) |
static void | ElementToStream(Element element, OutputStream out) |
static String | ElementToString(Element element)
turn an element into an XML fragment |
static void | ElementToWriter(Element element, Writer writer) |
static Node | findNode(Node node, QName name)
Find a Node with a given QName
|
static String | getChildCharacterData(Element parentEl)
Concat all the text and cdata node children of this elem and return
the resulting text.
(by Matt Duftler)
|
static DocumentBuilder | getDocumentBuilder()
Gets a DocumentBuilder |
static InputSource | getEmptyInputSource() |
static String | getEncoding(MessageContext msgContext)
Get the current encoding in effect |
static String | getEncoding()
Get the current encoding in effect |
static String | getEncoding(Message message, MessageContext msgContext) |
static String | getEncoding(Message message, MessageContext msgContext, XMLEncoder defaultEncoder) |
static QName | getFullQNameFromString(String str, Node e)
Return 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 | getInnerXMLString(Element element)
get the inner XML inside an element as a string. |
static InputSource | getInputSourceFromURI(String uri)
Utility to get the bytes uri.
|
static String | getNamespace(String prefix, Node e, Node stopNode)
Searches for the namespace URI of the given prefix in the given DOM range.
|
static String | getNamespace(String prefix, Node e) |
static String | getPrefix(String uri, Node e) |
static QName | getQNameFromString(String str, Node e)
Return 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 SAXParser | getSAXParser() Get a SAX parser instance from the JAXP factory.
|
static String | getStringForQName(QName qname, Element e)
Return a string for a particular QName, mapping a new prefix
if necessary. |
static XMLEncoder | getXMLEncoder(MessageContext msgContext)
Get the current XMLEncoder |
static XMLEncoder | getXMLEncoder(String encoding)
Get the XMLEncoder for specific encoding |
static void | initSAXFactory(String factoryClassName, boolean namespaceAware, boolean validating) Initialize the SAX parser factory.
|
static Document | newDocument()
Get an empty new Document
|
static Document | newDocument(InputSource inp)
Get a new Document read from the input source |
static Document | newDocument(InputStream inp)
Get a new Document read from the input stream |
static Document | newDocument(String uri)
Get a new Document read from the indicated uri |
static Document | newDocument(String uri, String username, String password)
Create a new document from the given URI, use the username and password
if the URI requires authentication. |
static void | normalize(Node node)
Trim all new lines from text nodes.
|
static void | privateElementToWriter(Element element, Writer writer, boolean omitXMLDecl, boolean pretty) |
static void | PrettyDocumentToStream(Document doc, OutputStream out) |
static String | PrettyDocumentToString(Document doc) |
static void | PrettyDocumentToWriter(Document doc, Writer writer) |
static void | PrettyElementToStream(Element element, OutputStream out) |
static void | PrettyElementToWriter(Element element, Writer writer) |
static void | releaseDocumentBuilder(DocumentBuilder db)
Releases a DocumentBuilder |
static void | releaseSAXParser(SAXParser parser) Return a SAX parser for reuse. |
static InputSource | sourceToInputSource(Source source)
Utility to get the bytes uri
|
static Element | StringToElement(String namespace, String name, String string)
Convert a simple string to an element with a text node
|
static String | trim(String str) |
static String | xmlEncodeString(String orig)
Encode a string appropriately for XML. |
Parameters: list List containing org.w3c.dom.Element objects
Returns: Element[] Array with org.w3c.dom.Element objects
Parameters: doc DOM document
Returns: string representation of the document, including XML declaration
Parameters: element
Returns: stringified element
Parameters: node parent node name QName of the child we need to find
Returns: child node
Parameters: parentEl the element whose cdata/text node values are to be combined.
Returns: the concatanated string.
Returns: DocumentBuilder
Throws: ParserConfigurationException
Returns: string
Returns: string
Returns: a QName generated from the given string representation
Parameters: element
Returns: textual body of the element, or null for no inner body
Parameters: uri the resource to get
See Also: XMLUtils
Parameters: prefix the prefix to find e the starting node stopNode null to search in all the document or a parent node where the search must stop.
Returns: null if no namespace is found, or the namespace URI.
Returns: a QName generated from the given string representation
Returns: a SAXParser instance.
Returns: XMLEncoder
Returns: XMLEncoder
Parameters: 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 parser validating true if we want a validating parser
Returns: Document
Throws: ParserConfigurationException if construction problems occur
Returns: Document
Throws: ParserConfigurationException if construction problems occur SAXException if the document has xml sax problems IOException if i/o exceptions occur
Returns: Document
Throws: ParserConfigurationException if construction problems occur SAXException if the document has xml sax problems IOException if i/o exceptions occur
Returns: Document
Throws: ParserConfigurationException if construction problems occur SAXException if the document has xml sax problems IOException if i/o exceptions occur
Parameters: uri the resource to get username basic auth username password basic auth password
Throws: ParserConfigurationException if construction problems occur SAXException if the document has xml sax problems IOException if i/o exceptions occur
Parameters: node
Parameters: db
Parameters: parser A SAX parser that is available for reuse
Parameters: source the resource to get
Parameters: namespace - element namespace name - element name string - value of the text node
Returns: element - an XML Element, null if no element was created
Parameters: orig the String to encode
Returns: a String in which XML special chars are repalced by entities