Database Reference
In-Depth Information
• Most XML IDEs provide content suggestion/completion when editing XSLT
stylesheets (e.g., by proposing elements or showing function declarations). If you
write your stylesheet embedded in an XQuery script, the IDE most likely cannot
provide such help due to the mixed-content model.
• When your code becomes sufficiently complex, you will probably want to test the
stylesheet separately from the surrounding XQuery code. This is much easier
when the stylesheet is a separate resource; for example, you may want to use
XSpec to execute your stylesheet against a series of behavior-driven development
(BBD)-style tests.
• When your stylesheet is separate, it is possible to run it through an XSLT debug‐
ger when you are trying to diagnose a problem. Such a debugger is available for
Saxon in the oXygen XML Editor .
• Separate XSLT stylesheets can often have their compiled form cached, making
repeated invocations faster.
Invoking XSLT with the Transform Extension Module
Performing XSLT transformations from your XQuery code can be done with eXist's
transform extension module. For instance:
transform:transform(
<input><text> hello XSLT </text></input> ,
'xmldb:exist:///db/myapp/convertinput.xslt',
<parameters><param name= "type" value= "basic" /></parameters>
)
The first argument is the node tree to transform; the second is the URI or document
element of the stylesheet. The third parameter passes the external parameter
type=basic to the stylesheet (which you can reference in the XSLT with a global
<xsl:param name="type"/> ).
The transform extension module offers two approaches for doing a transformation:
transform:stream-transform
Directly streams the result of the transformation to the output stream, returning
the empty sequence () . It is most commonly used as the final transformation
step for converting XML into HTML.
The only thing you'll see in your output is the output of transform:stream-
transform ; everything else is ignored. So, this is usually the last statement in a
script.
Search WWH ::




Custom Search