Esri Geoportal Server
1.0

com.esri.gpt.framework.xml
Class XmlIoUtil

java.lang.Object
  extended by com.esri.gpt.framework.xml.XmlIoUtil

public class XmlIoUtil
extends Object

Basic XML IO utitilies.


Method Summary
static String domToString(Document dom)
          Returns the xml string for a document.
static String jsonToXml(String xmlString, String rootElement)
          JSON To xml.
static String readXml(String systemId)
          Reads an xml string from a file or URL.
static void transform(Source source, Result result, boolean indent)
          Executes a transformation.
static String transform(String xml)
          Executes an identity transformation against an XML string.
static void writeXmlFile(String xml, File file)
          Writes an xml string to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

domToString

public static String domToString(Document dom)
                          throws TransformerException
Returns the xml string for a document.
The output encoding is set to UTF-8

Parameters:
dom - the xml Document
Returns:
the xml string
Throws:
TransformerException - if an exception occurs

readXml

public static String readXml(String systemId)
                      throws TransformerException
Reads an xml string from a file or URL.
The output encoding is set to UTF-8
systemId examples:
c:/somefolder/somefile.xml
file:///c:/somefolder/somefile.xml
http://www.somesitereturningxml.com

Parameters:
systemId - the system id of the file or URL to read
Returns:
the xml string
Throws:
TransformerException - if an exception occurs

transform

public static String transform(String xml)
                        throws TransformerException
Executes an identity transformation against an XML string.
The output encoding is set to UTF-8
The indent is set to "yes"

Parameters:
xml - the XML to transform
Returns:
the transformed xml
Throws:
TransformerException - if an exception occurs

transform

public static void transform(Source source,
                             Result result,
                             boolean indent)
                      throws TransformerException
Executes a transformation.
The output encoding is set to UTF-8
The indent is set to "yes"

Parameters:
source - the transformation source
result - the transformation result
indent - if true, the output indent key is set to "yes"
Throws:
TransformerException - if an exception occurs

writeXmlFile

public static void writeXmlFile(String xml,
                                File file)
                         throws TransformerException
Writes an xml string to a file.
The output encoding is set to UTF-8

Parameters:
file - the file to create
xml - them xml string
Throws:
TransformerException - if an exceition occurs

jsonToXml

public static String jsonToXml(String xmlString,
                               String rootElement)
                        throws Exception
JSON To xml.

Parameters:
xmlString - the xml string
rootElement - the root element that the xml should have. By default = gptJsonXml
Returns:
the xml.
Throws:
Exception - thrown if error while converting xmlString

Esri Geoportal Server
1.0

Copyright 2011 Environmental Systems Research Institute. All rights reserved. Use is subject to license terms.