|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: How recursively iterate over entire document?
Kenneth,
At 12:30 PM 8/13/2005, you wrote: Wendell, That's a name for the (emerging) idiom of binding a transformation result to a variable and then processing that as input. Classically this is done on the entire source document at once, through a "pipeline" of transformations. But in XSLT 2.0 (and in 1.0 using the node-set() extension) it can be done on just snippets or pieces of a document at once. So for example, I had a case where I wanted a new element, w:caption, to have the same semantics as a nested combination of other elements ... that is <picture id="schmidt-cover" frame="distinctive" width="120"
source="schmidt-cover.jpg">
<caption frame="caption" style="caption" x="0" y="175" width="165">
<line line-height="10"><i>Hall's Military
Breechloaders</i></line>
<line>Peter A Schmidt, 1996</line>
<line>Andrew Mowbray Publishers</line>
<line>PO Box 460 Lincoln RI 02865 USA</line>
<line>ISBN 0-917218-73-6</line>
</caption>
</picture>was to work exactly the same as (while being slightly easier to code than) <picture id="schmidt-cover" frame="distinctive" width="120" source="schmidt-cover.jpg"/> <hide id="schmidt-cover-caption"
show-when="schmidt-cover.click" hide-when="schmidt-cover-caption.click">
<panel frame="caption" style="caption"
x="0" y="175" width="165">
<line line-height="10"><i>Hall's Military
Breechloaders<:i></line>
<line>Peter A Schmidt, 1996</line>
<line>Andrew Mowbray Publishers</line>
<line>PO Box 460 Lincoln RI 02865 USA</line>
<line>ISBN 0-917218-73-6</line>
</panel>
</hide>Rather than duplicate all the code, or encapsulate the code for 'panel' in a place where 'caption' could get access to it, I decided simply to take the panel code as the normative version, and declare the caption to be merely a special variant. So (in XSLT 2.0) I could say <xsl:template match="wgll:caption"> <xsl:variable name="picture-id" select="parent::wgll:picture/@id"/> <xsl:variable name="caption-panel"> <wgll:hide id="{$picture-id}-caption" show-when="{$picture-id}.click" hide-when="{$picture-id}-caption.click"> <wgll:panel> <xsl:copy-of select="@*"/> <xsl:copy-of select="node()"/> </wgll:panel> </wgll:hide> </xsl:variable> <xsl:apply-templates select="$caption-panel"/> </xsl:template> The "micropipeline" is in the two-stage process: first, convert to something you already know how to process; second, process it. I still don't know, however, if this is good application design. Probably perfectly fine, I suppose, so long as it's documented (eheh). Cheers, Wendell
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








