public class XMLTransform extends DynamoServlet
Transform XML documents using a template.
The template can be a JHTML page or an XSLT stylesheet.
The input parameter specifies the XML document to
be transformed.
The template for the transformation
is located according to the following order of precedence:
XMLTemplateMap
component:
XMLTemplateMap
component.<?xml-stylesheet?>
processing instruction.
In the case of a JHTML template, the XMLTransform
droplet
will pass a DOM document as a local parameter to the execution of the
JHTML page.
The name of this parameter can be controlled by the optional
documentParameterName parameter.
The default is inputDocument
.
The DOM object that is the result of the transformation will be bound to the documentOutputName output parameter, for further processing or rendering in the output oparam.
If the output parameter is not specified,
the transformed document will be serialized directly into the page.
If the transform is XSL, the result will conform
to the <xsl:output>
top-level element.
These are the parameters for the XMLTransform
droplet:
Document
object,
a SAX InputSource
,
a text InputStream
,
or a URL for an XML document.
This parameter is required.
If it is not supplied, the unset open parameter will be rendered.
XMLTemplateMap
,
and finally from an <?xml-stylesheet?>
directive embedded in the XML document itself.
If no template is found, it is an error.
If logging is enabled, the reason will be logged,
then the failure open parameter will be rendered.
DOCTYPE
declaration.
Validation will be slower, but may help prevent problems later when
accessing parts of the XML document.
The legal values are: true
false
(default)nodtd
false
.
If there is no DOCTYPE
declaration,
this parameter has no effect.
<xsl:param>
elements in the XSL stylesheet.
Legal values are: none
: no params are passed (default).query
: URL query params from a GET request.post
: form params from a POST request.local
: only params in this droplet scope.all
: params from all droplet and request scopes.XMLTransform
droplet),
up through other enclosing scopes, and eventually to the
request query or post parameters.
See DynamoHttpServletRequest
for more details
on the query, post, and local parameter scope definitions.
inputDocument
.
document
.
documentOutputName
.
If the output oparam is not specified,
then the document is automatically serialized to the output page.
For more details about XSLT, see
XSL Transformations
(W3C Recommendation 1999-11-19).
In particular, see this section on
Top-level
Variables and Parameters, which mentions passing parameters
to stylesheets using <xsl:param>
elements.
For more details about embedded references to XSL stylesheets, see
Associating Stylesheets
with XML Documents (W3C Recommendation 1999-06-26).
When embedded XSL directives are used, the stylesheets from
multiple processing instructions are concatenated together,
as if they were imported into a common stylesheet.
There is no iteration over multiple stylesheets in the source
document, and no recursion over directives in the output of the
first transform.
The type
pseudo-attribute must be present,
with one of these values: text/xml
(official XSLT 1.0 MIME type),
text/xsl
(incorrect, but frequently used by analogy with
text/css
),
or application/xslt+xml
(newly suggested for XSLT by
RFC 3023 XML Media Types, but due to a typo in Xalan, you may need
to use application/xml+xslt
instead).
If the output open parameter is not specified for an XSL transform,
the serialized output will generally conform to the attributes of the
<xsl:output>
top-level element.
The MIME type is written to the HTTP response Content-type
header.
The MIME type is determined by an explicit media-type attribute
on the <xsl:output>
element.
If this is not present, then the MIME type is taken from the
Dynamo servlet pipeline, typically derived with the MIMETyper
from the filetype suffix of the page.
The default media-type
usually depends on the output
method attribute: text/xml
for method xml
,
and text/html
for the html
,
but in Dynamo this will always get overwritten with the
value from the pipeline.
The default method for Dynamo is html
,
not the standard XSL default value of xml
.
If XML output is required, it must be explicitly requested in the
<xsl:output>
element.
Since the MIME type can be derived from the Dynamo servlet pipeline,
it is possible to get an inconsistent method
in XSL
(e.g. a WML type from the servlet pipeline,
but a default html
output method).
Care should be taken to ensure that the MIME type and the
output method are consistent.
An encoding is used to serialize the result to the response stream,
and the encoding name is set in the Content-type
HTTP header
using the charset
flag.
The encoding is determined by an explicit encoding attribute
on the <xsl:output>
element.
If this is not present, then the encoding is taken from the
Dynamo servlet pipeline, typically derived with the EncodingTyper
from the path of the compiled page.
Note that the encoding does not default to the standard XSL value of UTF-8
,
and it is completely independent of the actual encoding of the XSL stylesheet itself,
as specified in the <?xml?>
declaration.
If an output encoding of UTF-8
is required,
it must be explicitly requested in the <xsl:output>
element.
XMLTemplateMap
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CLASS_VERSION |
protected static java.lang.String |
DEFAULT_IN_DOC_NAME
The default input document parameter name for JHTML
|
protected static java.lang.String |
DEFAULT_OUT_DOC_NAME
The default output document parameter name
|
protected static int |
DEFAULT_PASS |
protected static int |
ENUM_PASS_ALL |
protected static int |
ENUM_PASS_LOCAL |
protected static int |
ENUM_PASS_NONE |
protected static int |
ENUM_PASS_POST |
protected static int |
ENUM_PASS_QUERY |
protected static java.lang.String |
ERRORS_PARAM
The name of the errors paramameter
|
protected static java.lang.String |
FAILURE_PARAM
The name of the failure paramameter
|
protected static java.lang.String |
IN_DOC_NAME_PARAM
The name of the parameter used to configure the document
|
protected static java.lang.String |
INPUT_PARAM
The name of the input paramameter
|
protected static java.lang.String |
OUT_DOC_NAME_PARAM
The name of the default document parameter
|
protected static java.lang.String |
OUTPUT_PARAM
The name of the output paramameter
|
protected static java.lang.String |
PASS_ALL |
protected static java.lang.String |
PASS_LOCAL |
protected static java.lang.String |
PASS_NONE |
protected static java.lang.String |
PASS_PARAM
The name of the args paramameter
|
protected static java.lang.String |
PASS_POST |
protected static java.lang.String |
PASS_QUERY |
protected static java.lang.String |
TEMPLATE_CONTEXT_PARAM
The context path of the target template page (only applies to JSP).
|
protected static java.lang.String |
TEMPLATE_PARAM
The name of the template paramameter
|
protected static java.lang.String |
UNSET_PARAM
The name of the unset paramameter
|
protected static java.lang.String |
VALIDATE_PARAM
The name of the validate paramameter
|
mAllowCleanupRequest, mParameters
SERVLET_INFO_KEY
SERVICE_INFO_KEY
DEFAULT_LOG_TRACE_STATUS
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
Constructor and Description |
---|
XMLTransform() |
Modifier and Type | Method and Description |
---|---|
DocumentCache |
getDocumentCache()
The DocumentCache used by this component.
|
DocumentCache |
getStylesheetCache()
The StylesheetCache used by this component.
|
atg.xml.service.XMLTemplateMap |
getXmlTemplateMap()
The XMLTemplateMap used by this component.
|
atg.xml.tools.XMLToolsFactory |
getXmlToolsFactory()
The XMLToolsFactory used by this component.
|
protected void |
processJHTMLTemplate(DynamoHttpServletRequest pReq,
DynamoHttpServletResponse pRes,
org.w3c.dom.Document pInput,
java.lang.String pTemplateURI,
java.lang.String pInputDocParamName)
Process a JHTML template.
|
protected org.w3c.dom.Document |
processXSLTemplate(DynamoHttpServletRequest pReq,
DynamoHttpServletResponse pRes,
org.w3c.dom.Document pInput,
boolean output,
java.util.Map pParams,
javax.xml.transform.ErrorListener pErr)
Process with any embedded XSL template.
|
protected org.w3c.dom.Document |
processXSLTemplate(DynamoHttpServletRequest pReq,
DynamoHttpServletResponse pRes,
org.w3c.dom.Document pInput,
org.w3c.dom.Document pStylesheet,
boolean output,
java.util.Map pParams,
javax.xml.transform.ErrorListener pErr)
Process an XSL template from a DOM document.
|
protected org.w3c.dom.Document |
processXSLTemplate(DynamoHttpServletRequest pReq,
DynamoHttpServletResponse pRes,
org.w3c.dom.Document pInput,
java.lang.Object pXform,
boolean output,
java.util.Map pParams,
javax.xml.transform.ErrorListener pErr)
Process an XSL template with a pre-compiled template.
|
void |
service(DynamoHttpServletRequest pReq,
DynamoHttpServletResponse pRes)
The service method for this droplet.
|
void |
setDocumentCache(DocumentCache pDocumentCache)
The DocumentCache used by this component
|
void |
setStylesheetCache(DocumentCache pStylesheetCache)
The StylesheetCache used by this component
|
void |
setXmlTemplateMap(atg.xml.service.XMLTemplateMap pXMLTemplateMap)
The XMLTemplateMap used by this component
|
void |
setXmlToolsFactory(atg.xml.tools.XMLToolsFactory pXMLToolsFactory)
The XMLToolsFactory used by this component.
|
doDelete, doGet, doPost, doPut, getParameter, getParameters, getServletContext, init, service, service, setParameter
destroy, getServletConfig, getServletInfo, setServletInfo
getAverageRequestHandlingTime, getHandledRequestCount, getRequestStartTime, getTotalRequestHandlingTime, isKeepingStatistics, notifyHandledRequest, resetStatistics, setKeepingStatistics
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
public static java.lang.String CLASS_VERSION
protected static final java.lang.String INPUT_PARAM
protected static final java.lang.String OUT_DOC_NAME_PARAM
protected static final java.lang.String IN_DOC_NAME_PARAM
protected static final java.lang.String OUTPUT_PARAM
protected static final java.lang.String UNSET_PARAM
protected static final java.lang.String VALIDATE_PARAM
protected static final java.lang.String PASS_PARAM
protected static final java.lang.String TEMPLATE_PARAM
protected static final java.lang.String TEMPLATE_CONTEXT_PARAM
protected static final java.lang.String ERRORS_PARAM
protected static final java.lang.String FAILURE_PARAM
protected static final java.lang.String DEFAULT_IN_DOC_NAME
protected static final java.lang.String DEFAULT_OUT_DOC_NAME
protected static final java.lang.String PASS_NONE
protected static final java.lang.String PASS_LOCAL
protected static final java.lang.String PASS_QUERY
protected static final java.lang.String PASS_POST
protected static final java.lang.String PASS_ALL
protected static final int ENUM_PASS_NONE
protected static final int ENUM_PASS_LOCAL
protected static final int ENUM_PASS_QUERY
protected static final int ENUM_PASS_POST
protected static final int ENUM_PASS_ALL
protected static final int DEFAULT_PASS
public void setDocumentCache(DocumentCache pDocumentCache)
public DocumentCache getDocumentCache()
public void setStylesheetCache(DocumentCache pStylesheetCache)
public DocumentCache getStylesheetCache()
public void setXmlToolsFactory(atg.xml.tools.XMLToolsFactory pXMLToolsFactory)
public atg.xml.tools.XMLToolsFactory getXmlToolsFactory()
public void setXmlTemplateMap(atg.xml.service.XMLTemplateMap pXMLTemplateMap)
public atg.xml.service.XMLTemplateMap getXmlTemplateMap()
public void service(DynamoHttpServletRequest pReq, DynamoHttpServletResponse pRes) throws javax.servlet.ServletException, java.io.IOException
service
in class DynamoServlet
pReq
- the request to be processedpRes
- the response object for this requestjavax.servlet.ServletException
- an application specific error occurred
processing this requestjava.io.IOException
- an error occurred reading data from the request
or writing data to the response.protected org.w3c.dom.Document processXSLTemplate(DynamoHttpServletRequest pReq, DynamoHttpServletResponse pRes, org.w3c.dom.Document pInput, org.w3c.dom.Document pStylesheet, boolean output, java.util.Map pParams, javax.xml.transform.ErrorListener pErr) throws java.lang.Exception
java.lang.Exception
protected org.w3c.dom.Document processXSLTemplate(DynamoHttpServletRequest pReq, DynamoHttpServletResponse pRes, org.w3c.dom.Document pInput, java.lang.Object pXform, boolean output, java.util.Map pParams, javax.xml.transform.ErrorListener pErr) throws java.lang.Exception
java.lang.Exception
protected org.w3c.dom.Document processXSLTemplate(DynamoHttpServletRequest pReq, DynamoHttpServletResponse pRes, org.w3c.dom.Document pInput, boolean output, java.util.Map pParams, javax.xml.transform.ErrorListener pErr) throws java.lang.Exception
java.lang.Exception
protected void processJHTMLTemplate(DynamoHttpServletRequest pReq, DynamoHttpServletResponse pRes, org.w3c.dom.Document pInput, java.lang.String pTemplateURI, java.lang.String pInputDocParamName) throws java.lang.Exception
java.lang.Exception