[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: How recursively iterate over entire document?

Subject: Re: How recursively iterate over entire document?
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Mon, 15 Aug 2005 15:10:14 -0400
xslt copy entire document
Kenneth,

At 12:30 PM 8/13/2005, you wrote:
Wendell,

What is micropipelining?

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&apos;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&apos;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


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.