|
Subject: [xsl] Sorting and grouping unknown elements From: "Claus Jessing" <claus@xxxxxxxxxx> Date: Fri, 21 Sep 2007 13:47:35 +0200 |
Hi gurus
I'm very new to xml/xsl transformation and am faced with the following
problem. I have an xml file with a number of rows.
Each row contains an unknown (but identical in terms of element names)
set of elements. I would like to create a drop down list
for each element below my row element.
Eg. if I had this XML:
<rowset>
<row>
<make>Toyota</make>
<model>Yaris</model>
<color>Red</color>
</row>
<row>
<make>Toyota</make>
<model>Corolla</model>
<color>Blue</color>
</row>
</rowset>
I would like to get this html:
<select name="make">
<option>Toyota</option>
</select>
<select name="model">
<option>Corolla</option>
<option>Yaris</option>
</select>
<select name="color">
<option>Blue</option>
<option>Red</option>
</select>
And this XML:
<rowset>
<row>
<name>Joe</name>
<address>123 Wide Av.</address>
</row>
<row>
<name>Joe</name>
<address>321 Narrow St.</address>
</row>
</rowset>
Should produce this html:
<select name="name">
<option>Joe</option>
</select>
<select name="address">
<option>123 Wide Av.</option>
<option>321 Narrow St.</option>
</select>
I have tried with something like this and all sorts of different
tweeks but I cant get to work :(
<xsl:for-each select="row/*">
<xsl:sort/>
<xsl:param name="_param" select="name()"/>
Debug: <xsl:value-of select="$_param"/>
<xsl:for-each select="//{name()}[not(. = following::{name()})]">
<xsl:sort/>
<option><xsl:value-of select="."/></option>
</xsl:for-each>
</xsl:for-each>
Can anyone help me out here?
Thanks in advance...
--
Claus Jessing, jessing.dk
---------------------------------------------
M: +45 6061 0101, P: +45 4461 0101
E: claus@xxxxxxxxxx, IM: claus@xxxxxxxxxx
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl]Putting PHP Code in XSLT?, Thomas Løcke | Thread | Re: [xsl] Sorting and grouping unkn, David Carlisle |
| Re: [xsl]Putting PHP Code in XSLT?, David Carlisle | Date | Re: [xsl] Sorting and grouping unkn, David Carlisle |
| Month |