[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
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 |
(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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Dealing with WDDX-based data, Toni Geoly | Thread | simple instructions for FOP->PDF ?, miles thompson |
RE: Fwds Compat/Fallback Conformanc, Kay Michael | Date | parametrized xsl, Evgenii Bazarov |
Month |