Re: xsl loop for display in drop-down box

Subject: Re: xsl loop for display in drop-down box
From: "Seema Ramanathan" <sramanathan@xxxxxxxxxxxx>
Date: Thu, 23 Mar 2000 14:20:56 -0800
Thanks Charlie. But like you said Stylus does not pick the attribute and
Saxon gives me the following error:
"Cannot write an attribute when there is no open start tag"

Like you mentioned i inserted the
<FIRST Selected="Y">Nothing</FIRST>
tag in my XML.

And then i used the following XSL:

<select name="FIRST">
<xsl:variable name="tmp"><xsl:value-of
select="FIRST/@SELECTED"/></xsl:variable>
    <xsl:for-each select="FIRST">
        <xsl:element name="option">
        <xsl:value-of select="."/>
         <xsl:if test="@SELECTED='Y'">
              <xsl:attribute name="SELECTED"><xsl:value-of
select="($tmp)"/></xsl:attribute>
        </xsl:if>
       </xsl:element>
    </xsl:for-each>
</select>

I get my drop down without a blank but the selected element is not displayed
first in the drop-down.

Any more ideas????

Seema

----- Original Message -----
From: Charlie Cox <xmldev@xxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxx>
Sent: Thursday, March 23, 2000 5:21 AM
Subject: Re: xsl loop for display in drop-down box


> if you can, change your 'nothing' line to
> <FIRST Selected="Y">Nothing</FIRST>
> This will elimnate your blank line and still give you
> the option to mark the selected entry.
>
> then you can change your <option>...</option> to the
> following:
>
> <xsl:for-each select="FIRST">
> <xsl:element name="option">
>    <xsl:value-of select="."/>
>    <xsl:if select="@Selected='Y'">
>       <xsl:attribute name="Selected">Y</xsl:attribute>
>    </xsl:if>
>    <xsl:value-of select="($tmp)"/>
> </xsl:element>
> </xsl:for-each>
>
> I have noticed the stylus editor version 1.0 does not
> correctly pick up the attribute under the if command,
> but it does work correctly in Xalan (EA release). I
> have not yet tried this with Stylus 2.0,Xalan 1.0 or
> any other xsl parsers.
>
> hope this helps
> Charlie
>
> --- Seema Ramanathan <sramanathan@xxxxxxxxxxxx> wrote:
> > Hi
> >
> > I have the following XML tag:
> > <TITLE>
> > <FIRST>Something</FIRST>
> > <FIRST>Everything</FIRST>
> > <FIRST Selected="Nothing"></FIRST>
> > </TITLE>
> >
> > I want my XSL to display a drop down box with the
> > first option to be the selected one - that is
> > "Nothing" followed by the others (Something and
> > Everything).
> >
> > Here is the XSL i use:
> > <select name="FIRST">
> > <xsl:variable name="tmp"><xsl:value-of
> > select="FIRST/@SELECTED"/></xsl:variable>
> > <xsl:if test="(normalize($tmp)=true())">
> > <option><xsl:value-of select="($tmp)"/></option>
> > <xsl:for-each select="MODEL">
> > <option><xsl:value-of select="."/></option>
> > </xsl:for-each>
> > </xsl:if>
> > </select>
> >
> > When i use the above XSL loop I get a drop down with
> > "Nothing" displayed followed by "Something",
> > "Everything" and another blank option. How do i get
> > rid of the blank? I realize its coming from this
> > line "
> > <FIRST Selected="Nothing"></FIRST>".
> >
> > Is there any way i can ignore it?
> >
> > Any help??? Please and TIA
> >
> > Seema
> >
>
> __________________________________________________
> Do You Yahoo!?
> Talk to your friends online with Yahoo! Messenger.
> http://im.yahoo.com
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread