Skip navigation links

Oracle® Fusion Middleware Site Studio for External Applications Java API Reference
11g Release 1 (11.1.1)

E17273-02


oracle.stellent.wcm.common.xml
Class XMLHelper

java.lang.Object
  extended by oracle.stellent.wcm.common.xml.XMLHelper


public class XMLHelper
extends java.lang.Object

XML Helper methods for working with DOM structures


Field Summary
protected static java.lang.String AMP_REF
           
protected static java.lang.String APOS_REF
           
protected static java.lang.String CHAR_REF_START
           
protected static java.lang.String GT_REF
           
protected static java.lang.String LT_REF
           
protected static java.lang.String QUOT_REF
           

 

Constructor Summary
XMLHelper()
           

 

Method Summary
static javax.xml.transform.Transformer createPrettyPrintTransformer()
          Create a transformer class with the pretty print flags
static java.lang.String encodeXml(java.lang.String text)
          Encode the string for XML.
static int getAttributeAsInt(org.w3c.dom.Element element, java.lang.String name, int defaultValue)
          Retrieve the attribute value as an integer
static long getAttributeAsLong(org.w3c.dom.Element element, java.lang.String name, long defaultValue)
          Retrieve the attribute value as a long
static java.util.Map<java.lang.String,java.lang.String> getAttributes(org.w3c.dom.Element element)
          Retrieve the attributes from the given element as a mapping of String name to String value
static org.w3c.dom.Document parseXML(org.xml.sax.InputSource xmlSource, boolean validating, boolean namespaceAware)
          Parse xml from InputSource.
static org.w3c.dom.Document parseXML(java.io.InputStream xmlStream, boolean validating, boolean namespaceAware)
          Parse xml from the inputstream.
static org.w3c.dom.Document parseXML(java.io.Reader xmlReader, boolean validating, boolean namespaceAware)
          Parse xml from the Reader.
static void serialize(org.w3c.dom.Node rootNode, java.io.OutputStream out)
          Pretty prints the XML to the specified output stream
static void serialize(org.w3c.dom.Node rootNode, java.io.Writer out)
          Pretty prints the XML to the specified output stream
static java.lang.String toString(org.w3c.dom.Node rootNode)
          Pretty prints the XML and returns it as a stream

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

AMP_REF

protected static final java.lang.String AMP_REF
See Also:
Constant Field Values

APOS_REF

protected static final java.lang.String APOS_REF
See Also:
Constant Field Values

GT_REF

protected static final java.lang.String GT_REF
See Also:
Constant Field Values

LT_REF

protected static final java.lang.String LT_REF
See Also:
Constant Field Values

QUOT_REF

protected static final java.lang.String QUOT_REF
See Also:
Constant Field Values

CHAR_REF_START

protected static final java.lang.String CHAR_REF_START
See Also:
Constant Field Values

Constructor Detail

XMLHelper

public XMLHelper()

Method Detail

getAttributes

public static java.util.Map<java.lang.String,java.lang.String> getAttributes(org.w3c.dom.Element element)
Retrieve the attributes from the given element as a mapping of String name to String value
Parameters:
element - the element
Returns:
a map of attribute name to attribute value

getAttributeAsInt

public static int getAttributeAsInt(org.w3c.dom.Element element,
                                    java.lang.String name,
                                    int defaultValue)
Retrieve the attribute value as an integer
Parameters:
element - the element
name - the attribute name
defaultValue - the default value
Returns:
the attribute value or the default if the attribute could not be read or converted to an integer

getAttributeAsLong

public static long getAttributeAsLong(org.w3c.dom.Element element,
                                      java.lang.String name,
                                      long defaultValue)
Retrieve the attribute value as a long
Parameters:
element - the element
name - the attribute name
defaultValue - the default value
Returns:
the attribute value or the default if the attribute could not be read or converted to a long

toString

public static java.lang.String toString(org.w3c.dom.Node rootNode)
                                 throws javax.xml.transform.TransformerException
Pretty prints the XML and returns it as a stream
Parameters:
rootNode - the root node of the XML document to display
Returns:
the XML display
Throws:
javax.xml.transform.TransformerException

encodeXml

public static java.lang.String encodeXml(java.lang.String text)
Encode the string for XML. This will escape any reserved characters.
Parameters:
text - the unencoded text
Returns:
XML-encoded text

parseXML

public static org.w3c.dom.Document parseXML(java.io.InputStream xmlStream,
                                            boolean validating,
                                            boolean namespaceAware)
                                     throws java.io.IOException,
                                            javax.xml.parsers.ParserConfigurationException,
                                            org.xml.sax.SAXException
Parse xml from the inputstream.
Parameters:
xmlStream - the stream to the XML content
validating - true to validate the XML
namespaceAware - true to make the parser namespace aware
Returns:
the Document object
Throws:
java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException

parseXML

public static org.w3c.dom.Document parseXML(java.io.Reader xmlReader,
                                            boolean validating,
                                            boolean namespaceAware)
                                     throws java.io.IOException,
                                            javax.xml.parsers.ParserConfigurationException,
                                            org.xml.sax.SAXException
Parse xml from the Reader.
Parameters:
xmlReader - the reader to the XML content
validating - true to validate the XML
namespaceAware - true to make the parser namespace aware
Returns:
the Document object
Throws:
java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException

parseXML

public static org.w3c.dom.Document parseXML(org.xml.sax.InputSource xmlSource,
                                            boolean validating,
                                            boolean namespaceAware)
                                     throws java.io.IOException,
                                            javax.xml.parsers.ParserConfigurationException,
                                            org.xml.sax.SAXException
Parse xml from InputSource.
Parameters:
xmlSource - the inputSource to the XML content
validating - true to validate the XML
namespaceAware - true to make the parser namespace aware
Returns:
the Document object
Throws:
java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException

serialize

public static void serialize(org.w3c.dom.Node rootNode,
                             java.io.OutputStream out)
                      throws javax.xml.transform.TransformerException
Pretty prints the XML to the specified output stream
Parameters:
rootNode - the root node of the XML document to display
out - the output stream
Throws:
javax.xml.transform.TransformerException

serialize

public static void serialize(org.w3c.dom.Node rootNode,
                             java.io.Writer out)
                      throws javax.xml.transform.TransformerException
Pretty prints the XML to the specified output stream
Parameters:
rootNode - the root node of the XML document to display
out - the output stream
Throws:
javax.xml.transform.TransformerException

createPrettyPrintTransformer

public static javax.xml.transform.Transformer createPrettyPrintTransformer()
                                                                    throws javax.xml.transform.TransformerException
Create a transformer class with the pretty print flags
Returns:
the transformer setup for pretty printing
Throws:
javax.xml.transform.TransformerException

Skip navigation links

Oracle® Fusion Middleware Site Studio for External Applications Java API Reference
11g Release 1 (11.1.1)

E17273-02


Copyright © 2010, 2011, Oracle and/or its affiliates. All rights reserved.