[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Q on how create pick list
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|