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

Sorting and grouping unknown elements

Subject: Sorting and grouping unknown elements
From: "Claus Jessing" <claus@xxxxxxxxxx>
Date: Fri, 21 Sep 2007 13:47:35 +0200
 Sorting and grouping unknown elements
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

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.