Thanks David
Couldn't get your first example to work. I'm using javax.xml.transform
for the actual transformation and Eclipse tells me that for-each-group
is an unkown xsl element.
Your other example works just fine tho :-)
Thanks
Claus Jessing
On 9/21/07, David Carlisle <davidc(_at_)nag(_dot_)co(_dot_)uk> wrote:
oops I grouped the wrong thing, try
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:template match="rowset">
<xsl:for-each-group select="row/*" group-by="name()">
<xsl:sort select="name()"/>
<select name="{current-grouping-key()}">
<xsl:for-each-group select="current-group()" group-by=".">
<xsl:sort/>
<option><xsl:value-of select="."/></option>
</xsl:for-each-group>
</select>
</xsl:for-each-group>
</xsl:template>
</xsl:stylesheet>
$ saxon8 rs.xml rs2.xsl
<?xml version="1.0" encoding="UTF-8"?>
<select name="color">
<option>Blue</option>
<option>Red</option>
</select>
<select name="make">
<option>Toyota</option>
</select>
<select name="model">
<option>Corolla</option>
<option>Yaris</option>
</select>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:key name="n" match="*" use="name()"/>
<xsl:key name="v" match="*" use="concat(name(),.)"/>
<xsl:template match="rowset">
<xsl:for-each select="row/*[generate-id(.)=generate-id(key('n',name()))]">
<xsl:sort select="name()"/>
<select name="{name()}">
<xsl:for-each
select="../../row/*[generate-id(.)=generate-id(key('v',concat(name(current()),.)))]">
<xsl:sort/>
<option><xsl:value-of select="."/></option>
</xsl:for-each>
</select>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
$ saxon rs.xml rs1.xsl
<?xml version="1.0" encoding="utf-8"?>
<select name="color">
<option>Blue</option>
<option>Red</option>
</select>
<select name="make">
<option>Toyota</option>
</select>
<select name="model">
<option>Corolla</option>
<option>Yaris</option>
</select>
________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.
This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs.
________________________________________________________________________
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--
Claus Jessing, jessing.dk
---------------------------------------------
M: +45 6061 0101, P: +45 4461 0101
E: claus(_at_)jessing(_dot_)dk, IM: claus(_at_)jessing(_dot_)dk
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--