This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Q on how create pick list
- To: "Walter Torres" <walter at torres dot ws>
- Subject: Re: [xsl] Q on how create pick list
- From: Jeni Tennison <mail at jenitennison dot com>
- Date: Sat, 24 Feb 2001 09:49:30 +0000
- CC: xsl-list at lists dot mulberrytech dot com
- Organization: Jeni Tennison Consulting Ltd
- References: <007001c09dcc$fb224430$4454b23f@ELOY1499>
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi Walter,
> I have a small data set (see below) and I would like to create a
> browser select object that contains an item for each of the NODEs in
> my data set (see sample below)
It's probably easiest to think of this with a 'push' approach: think
about each of the elements in your source data set and what it becomes
in the result.
The first element in your source is that 'titles' element. You want
that to become a 'select' element with an 'id' attribute with a value
of 'titles' and a name with a value of 'titles'. So create a template
that matches the 'titles' element and creates the 'select' element
(and applies templates in the middle to move on to the content):
<!-- template matches the 'titles' element -->
<xsl:template match="titles">
<!-- creates a 'select' element with a 'name' and 'id' attribute
-->
<select name="titles" id="titles">
<!-- moves on to the content -->
<xsl:apply-templates />
</select>
</xsl:template>
Then, each of the 'display' elements maps onto an 'option' element in
the result. The value of the 'display' element becomes the value of
the 'option' element, and the value of the 'id' attribute of the
'display' element becomes the value of the 'value' attribute in the
result. Again, you need a template to do the mapping:
<!-- template matches a 'display' element -->
<xsl:template match="display">
<!-- creates an 'option' element. The 'value' attribute is given
the value of the 'id' attribute of the 'display' element. -->
<option value="{@id}">
<!-- gives the value of the 'display' element as the value of
the 'option' element -->
<xsl:value-of select="." />
</option>
</xsl:template>
I hope that helps,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list