com.esri.adf.web.util
Class XMLUtil

java.lang.Object
  extended by com.esri.adf.web.util.XMLUtil

public class XMLUtil
extends Object

Utility methods for standard XML operations.


Constructor Summary
XMLUtil()
           
 
Method Summary
static Element createCDATASection(Document doc, String elementName, String cdata, Element parentElement)
          Creates a new element within the XML document with the given elementName.
static Element createCDATASection(String elementName, String cdata, Element parentElement)
          Creates a new element within the owner XML document of the parentElement with the given elementName.
static void createCommonElements(Document doc, Element root, javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent component)
          Creates the common elements "client" and "common-resources-registered" under this root element which are shared by all controls.
static Element createElement(Document doc, String elementName, String elementValue, Element parentElement)
          Creates a new element within the XML document with the given elementName.
static Element createElement(String elementName, String elementValue, Element parentElement)
          Creates a new element within the owner XML document of the parentElement with the given elementName.
static void createLocalizedElements(Document doc, Element root)
           
static String getElementValue(String elementName, Element parentElement)
           
static Transformer getTransformer(URL url)
           
static String getValidStyleString(String styleString)
           
static Document newDocument()
          Creates a new XML Document object.
static String transform(Document xmlDoc, URL url)
          Transforms the xmlDoc using the xslFile and returns the transformed result as a string.
static String transform(Document xmlDoc, URL url, Properties outputFormat)
          Transforms the xmlDoc using the xslFile and returns the transformed result as a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLUtil

public XMLUtil()
Method Detail

newDocument

public static Document newDocument()
Creates a new XML Document object.

Returns:
Document- a new XML Document

getElementValue

public static String getElementValue(String elementName,
                                     Element parentElement)

createElement

public static Element createElement(Document doc,
                                    String elementName,
                                    String elementValue,
                                    Element parentElement)
Creates a new element within the XML document with the given elementName. If elementValue is not null, a new text node (with the value of elementValue) is added as a child of this new element. The new element is added as a child of the parentElement (if it is not null) or as a child of the document (if parentElement is null).

Parameters:
doc - the Document to add the new element to
elementName - the name of the new element
elementValue - the value of the new element
parentElement - the parent of the new element
Returns:
Element- the new element created

createElement

public static Element createElement(String elementName,
                                    String elementValue,
                                    Element parentElement)
Creates a new element within the owner XML document of the parentElement with the given elementName. If elementValue is not null, a new text node (with the value of elementValue) is added as a child of this new element. The new element is added as a child of the parentElement (if it is not null) or as a child of the document (if parentElement is null).

Parameters:
elementName - the name of the new element
elementValue - the value of the new element
parentElement - the parent of the new element
Returns:
Element- the new element created

createCDATASection

public static Element createCDATASection(Document doc,
                                         String elementName,
                                         String cdata,
                                         Element parentElement)
Creates a new element within the XML document with the given elementName. If elementValue is not null, a new CDATA section node (with the value of cdata) is added as a child of this new element. The new element is added as a child of the parentElement (if it is not null) or as a child of the document (if parentElement is null).

Parameters:
doc - the Document to add the new element to
elementName - the name of the new element
cdata - the CDATA value of the new element
parentElement - the parent of the new element
Returns:
Element- the new element created

createCDATASection

public static Element createCDATASection(String elementName,
                                         String cdata,
                                         Element parentElement)
Creates a new element within the owner XML document of the parentElement with the given elementName. If elementValue is not null, a new CDATA section (with the value of cdata) is added as a child of this new element. The new element is added as a child of the parentElement (if it is not null) or as a child of the document (if parentElement is null).

Parameters:
elementName - the name of the new element
cdata - the CDATA value of the new element
parentElement - the parent of the new element
Returns:
Element- the new element created

createCommonElements

public static void createCommonElements(Document doc,
                                        Element root,
                                        javax.faces.context.FacesContext facesContext,
                                        javax.faces.component.UIComponent component)
Creates the common elements "client" and "common-resources-registered" under this root element which are shared by all controls. The value of client is set to the type of browser client and the value of common-resources-registered is set to true or false based on whether another control has already been placed in the context.

Parameters:
doc - the document to add the elements to
root - the parent of the element to add

createLocalizedElements

public static void createLocalizedElements(Document doc,
                                           Element root)

transform

public static String transform(Document xmlDoc,
                               URL url)
Transforms the xmlDoc using the xslFile and returns the transformed result as a string. If xslFile is null, it returns the XML as a string.

Parameters:
xmlDoc - the XML document to transform
url - the URL of the XSL file which specifies how to transform
Returns:
String- the transformed result as a string

transform

public static String transform(Document xmlDoc,
                               URL url,
                               Properties outputFormat)
Transforms the xmlDoc using the xslFile and returns the transformed result as a string. If xslFile is null, it returns the XML as a string.

Parameters:
xmlDoc - the XML document to transform
url - the URL of the XSL file which specifies how to transform
outputFormat - the output properties that used for transformation
Returns:
String- the transformed result as a string
See Also:
Transformer.setOutputProperties(Properties)

getValidStyleString

public static String getValidStyleString(String styleString)

getTransformer

public static Transformer getTransformer(URL url)
                                  throws Exception
Throws:
Exception