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

Re: Dealing with WDDX-based data

Subject: Re: Dealing with WDDX-based data
From: Francis Norton <francis@xxxxxxxxxxx>
Date: Mon, 22 May 2000 19:27:01 +0100
xsl template wddx
(see below for solution)

Toni Geoly wrote:
> 
> I was wondering how many people were dealing with data sets
> that are generated using the WDDX protocol/DTD from
> ColdFusion.
> 
...
> 
> Are people working directly with this data, or instead
> using xsl:copy/xsl:copy-of to build new trees that are a
> bit more user-friendly?  

Yes, the column-first representation of the data is somewhat
counter-intuitive, and normally unhelpful.

However it's not a big deal. Here's a solution - someone may come up
with a cleaner, pure-recursion one, but this works.

D:\xmlSchema>type t.xml
<?xml version="1.0"?>
<root>
  <field name="field1">
    <string>field1.row1</string>
    <string>field1.row2</string>
    <string>field1.row3</string>
    <string>field1.row4</string>
  </field>
  <field name="field2">
    <string>field2.row1</string>
    <string>field2.row2</string>
    <string>field2.row3</string>
    <string>field2.row4</string>
  </field>
  <field name="field3">
    <string>field3.row1</string>
    <string>field3.row2</string>
    <string>field3.row3</string>
    <string>field3.row4</string>
  </field>
</root>


D:\xmlSchema>type t.xsl
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<!-- main body and loop -->
<xsl:template match="/">
  <html>
    <head>
      <title>Results</title>
    </head>
    <body>
      <table>
        <!-- get horizontal - <xsl:for-each> is inside the <tr> -->
        <tr>
          <xsl:for-each select="//field">
            <th>
              <xsl:apply-templates select="@name"/>
            </th>
          </xsl:for-each>
        </tr>
        <!-- get vertical - <tr>s are inside the <xsl:for-each>  -->
        <xsl:for-each select="//field[1]/string">
          <tr>
            <xsl:call-template name="row">
              <xsl:with-param name="row-no" select="position()"/>
            </xsl:call-template>
          </tr>
        </xsl:for-each>
      </table>
    </body>
  </html>
</xsl:template>

<!-- do a row here - use parameter to get position() into pattern -->
<xsl:template name="row">
  <xsl:param name="row-no"/>

  <xsl:for-each select="//field/string[position() = $row-no]">
    <td>
      <xsl:apply-templates/>
    </td>
  </xsl:for-each>
</xsl:template>
  
</xsl:stylesheet>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.