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

Re: Re: WDDX Recordset generic simplification

Subject: Re: Re: WDDX Recordset generic simplification
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 08 Nov 2006 11:18:51 -0500
Re:  Re: WDDX Recordset generic simplification
Dear Eric,

At 08:27 PM 11/7/2006, you wrote:

I have an excerpt of a wddx data being generated from query data in
ColdFusion 5 and I need to simplify the structure with an intermediate
xsl transform so that I can consume the simplified form in a mail merge

[snipped]


I realize the following code does not work but it is the
pull/procedural approach I keep getting stuck heading towards:

<xsl:template match="var/recordset">
<xsl:variable name="rowCount" select="@rowCount"/>
<xsl:variable name="fieldNames" select="@fieldNames"/>
<xsl:for-each from="1" to="$rowCount" index="row">
<xsl:element name="{../@name}">
<xsl:for-each list="$fieldNames" index="col">
<xsl:element name="{$fieldNames[$col]}">
<xsl:value-of select="field[@name=$col]::child[position()=$row]"/>
<xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:for-each>
</xsl:template>


Can anyone point me towards a better approach using a push/functional
approach to make simplification of wddx recordsets contextually
generic?

First, a simple question: are you using XSLT 2.0?


The reason I ask is that in XSLT 1.0 you can't generate nodes in the result by iterating over a set of numbers, which is effectively what you are trying to do here. xsl:for-each doesn't accept "from" and "to" attributes, as its purpose is to select a set of *nodes* (from the source tree) and operate with each of them in turn as the current node. (In this, it's really just a shortcut to allow you to do this locally without calling a new template rule, which is what you'd ordinarily do.)

Due to its expanded data model, however, in XSLT 2.0 you can say

<xsl:for-each select="1 to $rowCount">...</xsl:for-each>

and (due to the semantics of the 'to' operator) operate over a sequence of numbers (integers, actually), 1 to whatever $rowCount is.

Hence, in XSLT 2.0 the correction would be a simple syntax tweak.

In XSLT 1.0, however, you would have to execute this recursively, calling a template from itself and counting up to or down from $rowCount with a parameter as you did so, to effect a stop condition. (There are examples from that in the XSL FAQ.)

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

Cast Your Vote

We need your help – Vote for DataDirect XML Products!

  • Best SOA or XML site

Winners and finalists announced at SOA World Conference in November.

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-2007 All Rights Reserved.