Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 13th, 2004, 06:54 PM
Registered User
Join Date: Jan 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Create a semi-colon delimited value

  I need to create the default "value" attribute for the select box depending on which option values are "selected". So far I can get value=13. What I need is value=1;3. All I need to do is add a semi-colon after the first one. I just don't know how to do that when you can't use counters in XSLT.

 My input is as follows:
<select multiple="true" name="test" >
 <option value="1" selected="selected">one</option>
 <option value="2">two</option>
 <option value="3" selected="selected">three</option>
 <option value="4">four</option>

Here's my code:
   <xsl:when test="@multiple">
        <xsl:attribute name="value">
          <xsl:for-each select="option[@value and attribute::selected]/@value">
                       <xsl:when test="$counter &gt 1"></xsl:when>
                   <xsl:value-of select="."/>

      <xsl:attribute name="value">
    <xsl:value-of select="option[@value and attribute::selected]/@value"/>

Reply With Quote
  #2 (permalink)  
Old January 14th, 2004, 05:36 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts

If you want a semi-colon delimited list of all selected options you need:
<xsl:for-each select="option[@value and @selected]">
<xsl:value-of select="@value"/>
<xsl:if test="position() != last()">;</xsl:if>
I can't see the need for the @multiple test; this only tests for the existence of the attribute by the way, not if it is set to true.

Joe (MVP - xml)
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Delimited data MargateFan XSLT 2 May 22nd, 2006 05:10 AM
Tab delimited Split ajindal General .NET 1 April 25th, 2006 08:20 AM
Looking for a good example of a Semi-Bound Form howardb1 Access VBA 0 April 24th, 2006 04:27 PM
(Semi) Automating Mail merge to Word Cryolith Access VBA 0 July 6th, 2003 10:35 AM

All times are GMT -4. The time now is 04:55 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.