Skip navigation links

Oracle® Fusion Middleware Java API Reference for Oracle WebCenter Content Remote Intradoc Client (RIDC)
11g Release 1 (11.1)

E17274-04


oracle.stellent.ridc.common.xml
Class XMLHelper

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


public class XMLHelper
extends Object

XML Helper methods for working with DOM structures


Field Summary
protected static String AMP_REF
           
protected static String APOS_REF
           
protected static String CHAR_REF_START
           
protected static String GT_REF
           
protected static String LT_REF
           
protected static String QUOT_REF
           

 

Constructor Summary
XMLHelper()
           

 

Method Summary
static Transformer createPrettyPrintTransformer()
          Create a transformer class with the pretty print flags
static String encodeXml(String text)
          Encode the string for XML.
static int getAttributeAsInt(Element element, String name, int defaultValue)
          Retrieve the attribute value as an integer
static long getAttributeAsLong(Element element, String name, long defaultValue)
          Retrieve the attribute value as a long
static Map<String,String> getAttributes(Element element)
          Retrieve the attributes from the given element as a mapping of String name to String value
static Document parseXML(InputSource xmlSource, boolean validating, boolean namespaceAware)
          Parse xml from InputSource.
static Document parseXML(InputStream xmlStream, boolean validating, boolean namespaceAware)
          Parse xml from the inputstream.
static Document parseXML(Reader xmlReader, boolean validating, boolean namespaceAware)
          Parse xml from the Reader.
static void serialize(Node rootNode, OutputStream out)
          Pretty prints the XML to the specified output stream
static void serialize(Node rootNode, Writer out)
          Pretty prints the XML to the specified output stream
static String toString(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 String AMP_REF
See Also:
Constant Field Values

APOS_REF

protected static final String APOS_REF
See Also:
Constant Field Values

GT_REF

protected static final String GT_REF
See Also:
Constant Field Values

LT_REF

protected static final String LT_REF
See Also:
Constant Field Values

QUOT_REF

protected static final String QUOT_REF
See Also:
Constant Field Values

CHAR_REF_START

protected static final String CHAR_REF_START
See Also:
Constant Field Values

Constructor Detail

XMLHelper

public XMLHelper()

Method Detail

getAttributes

public static Map<String,String> getAttributes(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(Element element,
                                    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(Element element,
                                      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 String toString(Node rootNode)
                       throws 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:
TransformerException

encodeXml

public static String encodeXml(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 Document parseXML(InputStream xmlStream,
                                boolean validating,
                                boolean namespaceAware)
                         throws IOException,
                                ParserConfigurationException,
                                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:
IOException
ParserConfigurationException
SAXException

parseXML

public static Document parseXML(Reader xmlReader,
                                boolean validating,
                                boolean namespaceAware)
                         throws IOException,
                                ParserConfigurationException,
                                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:
IOException
ParserConfigurationException
SAXException

parseXML

public static Document parseXML(InputSource xmlSource,
                                boolean validating,
                                boolean namespaceAware)
                         throws IOException,
                                ParserConfigurationException,
                                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:
IOException
ParserConfigurationException
SAXException

serialize

public static void serialize(Node rootNode,
                             OutputStream out)
                      throws 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:
TransformerException

serialize

public static void serialize(Node rootNode,
                             Writer out)
                      throws 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:
TransformerException

createPrettyPrintTransformer

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

Skip navigation links

Oracle® Fusion Middleware Java API Reference for Oracle WebCenter Content Remote Intradoc Client (RIDC)
11g Release 1 (11.1)

E17274-04


Copyright © 2008, 2013, Oracle and/or its affiliates. All rights reserved.