Esri Geoportal Server
1.0

com.esri.gpt.framework.xml
Class XsltTemplate

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

public class XsltTemplate
extends Object

Repesents a compiled XSLT transformation stylesheet.


Constructor Summary
XsltTemplate()
          Default constructor.
 
Method Summary
protected  void compileFromResourcePath(String resourcePath)
          Compiles the XSLT based upon a relative resource path.
protected  void compileFromSystemId(String systemId)
          Compiles the XSLT based upon a system path.
protected  String getSystemId()
          Gets the system id for the XSLT.
protected  Templates getTemplates()
          Gets the compiled transformer templates.
static XsltTemplate makeFromResourcePath(String resourcePath)
          Makes a compiled XSLT template based upon a relative resource path.
static XsltTemplate makeFromSystemId(String systemId)
          Makes a compiled XSLT template based upon a system path.
static XsltTemplate makeTemplate(String path)
          Makes a template by trying out various mechanisms to find the correct path
protected  void setSystemId(String systemId)
          Sets the system id for the XSLT.
protected  void setTemplates(Templates templates)
          Sets the compiled transformer templates.
 Result transform(Source source, Result result, Map mapParams)
          Transforms an xml document using the parameters specified.
 String transform(String xml)
          Transforms an xml document using the parameters specifiled.
 String transform(String xml, Map mapParams)
          Transforms an xml document using the parameters specified.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XsltTemplate

public XsltTemplate()
Default constructor.

Method Detail

getSystemId

protected final String getSystemId()
Gets the system id for the XSLT.

Returns:
the system id

setSystemId

protected final void setSystemId(String systemId)
Sets the system id for the XSLT.

Parameters:
systemId - the system id

getTemplates

protected final Templates getTemplates()
Gets the compiled transformer templates.

Returns:
the compiled templates

setTemplates

protected final void setTemplates(Templates templates)
Sets the compiled transformer templates.

Parameters:
templates - compiled templates

compileFromResourcePath

protected void compileFromResourcePath(String resourcePath)
                                throws IOException,
                                       TransformerConfigurationException
Compiles the XSLT based upon a relative resource path.
The resource path should be relative to the WEB-INF/classes folder. If the XSLT is located at:
/WEB-INF/classes/somefolder/somefile.xslt then supply a relative resource path of:
somefolder/somefile.xslt

Parameters:
resourcePath - the relative resource path to XSLT file
Throws:
IOException - if the is an io problem with the XSLT file
TransformerConfigurationException - if a configuration exception occurs

compileFromSystemId

protected void compileFromSystemId(String systemId)
                            throws TransformerConfigurationException
Compiles the XSLT based upon a system path.
systemId examples:
c:/somefolder/somefile.xslt
file:///c:/somefolder/somefile.xslt

Parameters:
systemId - the system path to XSLT file
Throws:
TransformerConfigurationException - if a configuration exception occurs

makeFromResourcePath

public static XsltTemplate makeFromResourcePath(String resourcePath)
                                         throws IOException,
                                                TransformerConfigurationException
Makes a compiled XSLT template based upon a relative resource path.
The resource path should be relative to the WEB-INF/classes folder. If the XSLT is located at:
/WEB-INF/classes/somefolder/somefile.xslt then supply a relative resource path of:
somefolder/somefile.xslt

Parameters:
resourcePath - the relative resource path to XSLT file
Returns:
the XSLT template
Throws:
TransformerConfigurationException - if a configuration exception occurs
IOException

makeFromSystemId

public static XsltTemplate makeFromSystemId(String systemId)
                                     throws TransformerConfigurationException
Makes a compiled XSLT template based upon a system path.
systemId examples:
c:/somefolder/somefile.xslt
file:///c:/somefolder/somefile.xslt

Parameters:
systemId - the system path to XSLT file
Returns:
the XSLT template
Throws:
TransformerConfigurationException - if a configuration exception occurs

makeTemplate

public static XsltTemplate makeTemplate(String path)
                                 throws TransformerConfigurationException
Makes a template by trying out various mechanisms to find the correct path

Parameters:
path - or system id
Returns:
XsltTemplate
Throws:
TransformerConfigurationException - when template cannot be made

transform

public String transform(String xml)
                 throws TransformerException,
                        TransformerConfigurationException
Transforms an xml document using the parameters specifiled.

Parameters:
xml - document to be transformed
Returns:
resulting xml document
Throws:
TransformerException - if an exception occurs during transformation
TransformerConfigurationException - if a configuration exception occurs

transform

public String transform(String xml,
                        Map mapParams)
                 throws TransformerException,
                        TransformerConfigurationException
Transforms an xml document using the parameters specified.

Parameters:
xml - document to be transformed
mapParams - parameters to be used for transformation (can be null)
Returns:
resulting xml document
Throws:
TransformerException - if an exception occurs during transformation
TransformerConfigurationException - if a configuration exception occurs

transform

public Result transform(Source source,
                        Result result,
                        Map mapParams)
                 throws TransformerException,
                        TransformerConfigurationException
Transforms an xml document using the parameters specified.

Parameters:
source - the source
result - the result
mapParams - the map params (can be null)
Returns:
the result
Throws:
TransformerException - the transformer exception
TransformerConfigurationException - the transformer configuration exception

Esri Geoportal Server
1.0

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