11.11 XML Transform Actions

   

The XML transform actions let you transform XML with XSTL. Table 11.25 lists the XML transform actions.

Table 11.25. XML Transform Actions

Action

Description

<x:transform>

Transforms an XML document, using an XSLT stylesheet.

<x:param>

Specifies a parameter for an XSLT transformation.

<x:transform>

Transforms an XML document, using an XSLT stylesheet

Syntax: [34]

[34] Items in brackets are optional.

Syntax #1: Without a body

 <x:transform xml xslt [xmlSystemId] [xsltSystemId]      [{var [scope]  result}]/> 

Syntax #2: With a body that specifies transformation parameters in the body

 <x:transform xml xslt [xmlSystemId] [xsltSystemId]      [{var [scope]  result}]>  <x:param> actions  </x:transform> 

Syntax #3: With a body that specifies an XML document and optional transformation parameters in the body

 <x:transform xslt [xmlSystemId] [xsltSystemId]      [{var [scope]  result}]>  xml   optional <x:param> actions  </x:transform> 

Description:

The <x:transform> action transforms an XML document, using an XSLT stylesheet.

Attributes:

Attribute [a]

Type

Description

xml

String, java.io.Reader, javax.xml.transform.Source, org.w3c.dom.Document, or an object exported by <x:set> or <x:parse>

The XML document that <x:transform> transforms.

xslt

String, Reader, or java.xml.transform.Source

The XSLT stylesheet that's applied to the XML document specified with the xml attribute.

xmlSystemId

String

A system identifier for parsing the XML document.

xsltSystemId

String

A system identifier for parsing the XSLT stylesheet.

result

javax.xml.transform.Result

An object that captures the transformation result.

var

String

The name of a scoped variable that references the transformed XML document.

scope

String

The scope of the scoped variable whose name is specified by the var attribute; default is page scope.

[a] static dynamic

Constraints and Error Handling:

  • If the XML document specified with the xml attribute is null or an empty string, <x:transform> throws a JspException .

  • If the XSLT document specified with the xslt attribute is null or an empty string, <x:transform> throws a JspException .

In a Nutshell :

By default, <x:transform> sends the transformed XML document to the current JspWriter . You can specify the name of a scoped variable that references an org.w3c.dom.Document object representing the transformed document with the var attribute. You can also specify a scope for that variable with the scope attribute.

You can also save the transformed XML document in an object whose type is javax.xml.transform.Result by specifying the object's name with the result attribute.

Additionally, you can specify URIs for the xmlSystemId and xsltSystemId attributes, which are used to locate external entities for the XML document and XSLT stylesheet, respectively.

<x:param>

Specifies a parameter for an XSLT transformation

Syntax:

Syntax #1: Without a body, with a value specified by the value attribute

 <x:param name value/> 

Syntax #2: With a body, specifying a value in the body of the action

 <x:param name>  value  </x:param> 

Description:

The <x:param> action specifies a parameter for an XSLT transformation.

Attributes:

Attribute [a]

Type

Description

name

String

The name of the transformation parameter.

value

Object

The value of the transformation parameter.

[a] static dynamic

In a Nutshell:

All action:nutshell summary]><x:param> actions must reside in the body of an <x:transform> action; the former sets a transformation parameter for the latter. You must specify the name of the parameter with the name attribute. You can specify the value of the parameter with the value attribute or in the body of the <x:param> action.

   


Core JSTL[c] Mastering the JSP Standard Tag Library
Core JSTL[c] Mastering the JSP Standard Tag Library
ISBN: 131001531
EAN: N/A
Year: 2005
Pages: 124

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net