com.plumtree.openfoundation.xml.dom
Class XPBuilder

java.lang.Object
  extended bycom.plumtree.openfoundation.xml.dom.XPBuilder

public class XPBuilder
extends java.lang.Object

XML parser utility.

Author:
djc

Constructor Summary
XPBuilder()
           
 
Method Summary
static byte[] GetDocumentAsByteArray(XPDocument doc)
          Returns the marked-up document as a byte array using the encoding of the underlying document if there is one, otherwise default encoding is UTF-8.
static byte[] GetDocumentAsByteArray(XPDocument doc, java.lang.String encoding)
          Returns the marked-up document as a byte array using the encoding specified.
static java.lang.String GetDocumentString(XPDocument doc)
          Deprecated. As of XDK Release 2.4.5.0 use GetDocumentAsByteArray(com.plumtree.openfoundation.xml.dom.XPDocument)instead.
static XPDocument LoadDocument(java.lang.String _strFileName)
          Loads an XML document from a file amd return an encoded XPDocument object.
static XPDocument LoadDocument(java.lang.String _strFileName, java.lang.String _strXMLDTD, boolean _bIgnoreWhitespace)
          Loads an XML document from a file using LoadDocumentFromString() method.
static XPDocument LoadDocumentFromByteArray(byte[] byteXML)
          Loads an XML document from byte array representation, with preset options to ignore DTD and retain whitespace characters.
static XPDocument LoadDocumentFromByteArray(byte[] byteXML, java.lang.String _strXMLDTD, boolean _bIgnoreWhitespace)
          Loads an XML document from byte array representation.
static XPDocument LoadDocumentFromString(java.lang.String _strXML)
          Loads an XML document from a String representation, with preset options to ignore DTD and retain whitespace characters.
static XPDocument LoadDocumentFromString(java.lang.String _strXML, java.lang.String _strXMLDTD, boolean _bIgnoreWhitespace)
          Loads an XML document from a String representation.
static XPDocument LoadDocumentFromURI(java.lang.String uri)
          Loads an XML file by locating its URI.
static void SaveDocument(java.lang.String fileName, XPDocument doc)
          Saves document to specified file location.
static void SaveDocument(java.lang.String fileName, XPDocument doc, boolean bPretty)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XPBuilder

public XPBuilder()
Method Detail

LoadDocumentFromString

public static XPDocument LoadDocumentFromString(java.lang.String _strXML,
                                                java.lang.String _strXMLDTD,
                                                boolean _bIgnoreWhitespace)
Loads an XML document from a String representation.

Parameters:
_strXML - - the String representation of the input XML.
_strXMLDTD - - DTD file to validate the input XML.
_bIgnoreWhitespace - - true to ignore whitespace characters, false if otherwise.
Returns:
XPDocument object representing the newly loaded XML document.

LoadDocumentFromString

public static XPDocument LoadDocumentFromString(java.lang.String _strXML)
Loads an XML document from a String representation, with preset options to ignore DTD and retain whitespace characters.

Parameters:
_strXML - - the String representation of the XML
Returns:
newly loaded document represented by XPDocument.

LoadDocumentFromByteArray

public static XPDocument LoadDocumentFromByteArray(byte[] byteXML,
                                                   java.lang.String _strXMLDTD,
                                                   boolean _bIgnoreWhitespace)
Loads an XML document from byte array representation.

Parameters:
byteXML - - the byte array representation of the input XML.
_strXMLDTD - - DTD file to validate the input XML.
_bIgnoreWhitespace - - true to ignore whitespace characters, false if otherwise.
Returns:
newly loaded document represented by XPDocument.

LoadDocumentFromByteArray

public static XPDocument LoadDocumentFromByteArray(byte[] byteXML)
Loads an XML document from byte array representation, with preset options to ignore DTD and retain whitespace characters.

Parameters:
byteXML - - the byte array representation of the input XML.
Returns:
newly loaded document represented by XPDocument.

LoadDocument

public static XPDocument LoadDocument(java.lang.String _strFileName,
                                      java.lang.String _strXMLDTD,
                                      boolean _bIgnoreWhitespace)
Loads an XML document from a file using LoadDocumentFromString() method.

Parameters:
_strFileName - - file of the input XML.
_strXMLDTD - - DTD file to validate the input XML.
_bIgnoreWhitespace - - true to ignore whitespace characters, false if otherwise.
Returns:
newly loaded document represented by XPDocument.

LoadDocument

public static XPDocument LoadDocument(java.lang.String _strFileName)
Loads an XML document from a file amd return an encoded XPDocument object.

Parameters:
_strFileName - - filename to locate
Returns:
newly loaded document

LoadDocumentFromURI

public static XPDocument LoadDocumentFromURI(java.lang.String uri)
Loads an XML file by locating its URI.

Parameters:
uri - URI to locate input XML.
Returns:
newly loaded document represented by XPDocument.

GetDocumentString

public static java.lang.String GetDocumentString(XPDocument doc)
Deprecated. As of XDK Release 2.4.5.0 use GetDocumentAsByteArray(com.plumtree.openfoundation.xml.dom.XPDocument)instead.

Returns the marked-up document as a String. Intuitively this might be seen as ToString() from the document. For cross-platform reasons, it is placed in the XPBuilder class instead.

Parameters:
doc - - document to be represented as a string
Returns:
Document marked-up as a String

GetDocumentAsByteArray

public static byte[] GetDocumentAsByteArray(XPDocument doc)
Returns the marked-up document as a byte array using the encoding of the underlying document if there is one, otherwise default encoding is UTF-8. Intuitively this might be seen as ToByteArray() from the document.

Parameters:
doc - - document to be represented as a byte array
Returns:
Document marked-up as a byte array

GetDocumentAsByteArray

public static byte[] GetDocumentAsByteArray(XPDocument doc,
                                            java.lang.String encoding)
Returns the marked-up document as a byte array using the encoding specified. Default to UTF-8 if encoding is null. Make sure the encoding is compatible with the charsets supported in Charset. Intuitively this might be seen as ToByteArray() from the document.

Parameters:
doc - - document to be represented as a byte array
encoding - - encoding for the byte array
Returns:
Document serialized as a byte array

SaveDocument

public static void SaveDocument(java.lang.String fileName,
                                XPDocument doc)
Saves document to specified file location.

Parameters:
fileName - - location of file name
doc - - document to be saved

SaveDocument

public static void SaveDocument(java.lang.String fileName,
                                XPDocument doc,
                                boolean bPretty)


Copyright 2002, 2003, 2004 Plumtree Software Inc. All Rights Reserved.