Package org.apache.axis2.util
Class XMLUtils
java.lang.Object
org.apache.axis2.util.XMLUtils
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringbase64encode(byte[] bytes) static NodeFinds a Node with a given QNameb.static StringgetChildCharacterData(Element parentEl) Concatinates all the text and cdata node children of this elem and returns the resulting text.static InputSourcestatic InputSourceUtility to get the bytes uri.static StringgetNamespace(String prefix, Node e) static Stringstatic QNamegetQNameFromString(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 StringgetStringForQName(QName qname, Element e) Returns a string for a particular QName, mapping a new prefix if necessary.static voidinitSAXFactory(String factoryClassName, boolean namespaceAware, boolean validating) Initializes the SAX parser factory.static DocumentGets an empty new Document.static DocumentnewDocument(InputStream inp) Gets a new Document read from the input streamstatic DocumentnewDocument(String uri) Gets a new Document read from the indicated uristatic DocumentnewDocument(String uri, String username, String password) Creates a new document from the given URI.static DocumentnewDocument(InputSource inp) Gets a new Document read from the input source.static voidreleaseSAXParser(SAXParser parser) Returns a SAX parser for reuse.static ElementtoDOM(org.apache.axiom.om.OMElement element) Converts a given OMElement to a DOM Element.static org.apache.axiom.om.OMNodetoOM(InputStream inputStream) Converts a given inputstream to an OMNode The reurned OMNode is fully built.static org.apache.axiom.om.OMNodetoOM(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.OMNodeConverts a given Reader to an OMNode.static org.apache.axiom.om.OMNodeConverts a given Reader to an OMNode.static org.apache.axiom.om.OMElementConvert DOM Element into a fully built OMElement
-
Field Details
-
charEncoding
- See Also:
-
-
Constructor Details
-
XMLUtils
public XMLUtils()
-
-
Method Details
-
initSAXFactory
public static void initSAXFactory(String factoryClassName, boolean namespaceAware, boolean validating) Initializes the SAX parser factory.- 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. Ifnull, leaves current setting alone.namespaceAware- true if we want a namespace-aware parservalidating- true if we want a validating parser
-
releaseSAXParser
Returns a SAX parser for reuse.- Parameters:
parser- A SAX parser that is available for reuse
-
newDocument
Gets an empty new Document.- Returns:
- Returns Document.
- Throws:
ParserConfigurationException- if construction problems occur
-
newDocument
public static Document newDocument(InputSource inp) throws ParserConfigurationException, SAXException, IOException Gets a new Document read from the input source.- Returns:
- Returns Document.
- Throws:
ParserConfigurationException- if construction problems occurSAXException- if the document has xml sax problemsIOException- if i/o exceptions occur
-
newDocument
public static Document newDocument(InputStream inp) throws ParserConfigurationException, SAXException, IOException Gets a new Document read from the input stream- Returns:
- Returns Document.
- Throws:
ParserConfigurationException- if construction problems occurSAXException- if the document has xml sax problemsIOException- if i/o exceptions occur
-
newDocument
public static Document newDocument(String uri) throws ParserConfigurationException, SAXException, IOException Gets a new Document read from the indicated uri- Returns:
- Returns Document.
- Throws:
ParserConfigurationException- if construction problems occurSAXException- if the document has xml sax problemsIOException- if i/o exceptions occur
-
newDocument
public static Document newDocument(String uri, String username, String password) throws ParserConfigurationException, SAXException, IOException Creates a new document from the given URI. Uses the username and password if the URI requires authentication.- Parameters:
uri- the resource to getusername- basic auth usernamepassword- basic auth password- Throws:
ParserConfigurationException- if construction problems occurSAXException- if the document has xml sax problemsIOException- if i/o exceptions occur
-
getPrefix
-
getNamespace
-
getQNameFromString
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.- Returns:
- Returns a QName generated from the given string representation.
-
getStringForQName
Returns a string for a particular QName, mapping a new prefix if necessary. -
getChildCharacterData
Concatinates all the text and cdata node children of this elem and returns the resulting text. (by Matt Duftler)- Parameters:
parentEl- the element whose cdata/text node values are to be combined.- Returns:
- Returns the concatinated string.
-
getInputSourceFromURI
Utility to get the bytes uri. Does NOT handle authenticated URLs, use getInputSourceFromURI(uri, username, password)- Parameters:
uri- the resource to get
-
base64encode
-
getEmptyInputSource
-
findNode
Finds a Node with a given QNameb.- Parameters:
node- parent nodename- QName of the child we need to find- Returns:
- Returns child node.
-
toOM
Convert DOM Element into a fully built OMElement- Parameters:
element- dom Element- Returns:
- OMElement
- Throws:
Exception
-
toDOM
Converts a given OMElement to a DOM Element.- Parameters:
element-- Returns:
- Returns Element.
- Throws:
Exception
-
toOM
Converts a given inputstream to an OMNode The reurned OMNode is fully built.- Parameters:
inputStream-- Returns:
- OMNode
- Throws:
XMLStreamException
-
toOM
public static org.apache.axiom.om.OMNode toOM(InputStream inputStream, boolean buildAll) throws XMLStreamException Converts a given inputstream to an OMNode The reurned OMNode is fully built if buildAll is true. If buildAll is false, the caller is responsible for closing the parser.- Parameters:
inputStream-buildAll-- Returns:
- OMNode
- Throws:
XMLStreamException
-
toOM
Converts a given Reader to an OMNode. The reurned OMNode is fully built.- Parameters:
reader-- Returns:
- Throws:
XMLStreamException
-
toOM
public static org.apache.axiom.om.OMNode toOM(Reader reader, boolean buildAll) throws XMLStreamException Converts a given Reader to an OMNode. The reurned OMNode is fully built if buildAll is true. If buildAll is false, the caller is responsible for closing the parser.- Parameters:
reader-buildAll-- Returns:
- OMNode
- Throws:
XMLStreamException
-