- From: Alex Milowski <alex@milowski.org>
- Date: Sat, 14 Jan 2006 09:17:52 -0800
- To: Erik Bruchez <ebruchez@orbeon.com>
- CC: public-xml-processing-model-wg@w3.org
Erik Bruchez wrote:
> But you can as well refer to other infosets produced earlier in the
> pipeline:
>
> <p:processor name="xpl:xslt">
> <p:input name="stylesheet" infosetref="#my-stylesheet"/>
> <p:input name="data" infosetref="#my-document"/>
> <p:output name="data" infoset="my-result"/>
> </p:processor>
In smallx, there is a variant of this where is there is no stylesheet
specified as a parameter to the step, it operates on the document
looking for a specific '[c:]apply-xslt' element in the main input
infoset to the step.
There are three main examples of use:
<p:pipe xmlns:p="http://www.smallx.com/Vocabulary/Pipeline/2005/1/0"
xmlns:c="http://www.smallx.com/Vocabulary/Pipeline/Component/2005/1/0"
name="dynamic-xslt">
<p:document>
<doc>
<c:apply-xslt src="a2b.xsl">
<a/>
</c:apply-xslt>
</doc>
</p:document>
<p:xslt/>
</p:pipe>
Here the [c:]apply-xslt element is replaced by the result of
transforming the 'a' subtree with the 'a2b.xsl' transformation.
Alternately, you can embed the transfomation:
<p:pipe xmlns:p="http://www.smallx.com/Vocabulary/Pipeline/2005/1/0"
xmlns:c="http://www.smallx.com/Vocabulary/Pipeline/Component/2005/1/0"
name="dynamic-xslt">
<p:document>
<doc>
<c:apply-xslt>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="a">
<b/>
</xsl:template>
<xsl:template match="*|@*">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:transform>
<a/>
</c:apply-xslt>
</doc>
</p:document>
<p:xslt/>
</p:pipe>
Here the embedded transformation is applied to the 'a' element as its
own document. The result of that transformation replaces the
[c:]apply-xslt element in the output.
The result in both cases is:
<doc><b/></doc>
In terms of specifying parameters to stylesheets, a [c:]parameter
element is allowed as a child of [c:]apply-xslt to bind parameter
values or documents to XSLT parameters.
<p:pipe xmlns:p="http://www.smallx.com/Vocabulary/Pipeline/2005/1/0"
xmlns:c="http://www.smallx.com/Vocabulary/Pipeline/Component/2005/1/0"
xmlns:n="http://www.example.com"
name="dynamic-xslt">
<p:document>
<doc>
<c:apply-xslt src="xslt-param.xsl">
<c:parameter name="a">A value</c:parameter>
<c:parameter name="b">B value</c:parameter>
<c:parameter name="c">C value</c:parameter>
<c:parameter name="n:c">C namespace value</c:parameter>
<c:parameter name="doc">
<subtree>
<a/><b/><c/>
</subtree>
</c:parameter>
<a/>
</c:apply-xslt>
</doc>
</p:document>
<p:xslt/>
</p:pipe>
The most interesting bit here is the parameter 'doc' that is its own
document element being passed as a parameter.
--Alex Milowski
Received on Saturday, 14 January 2006 17:18:02 UTC