Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: To Populate Dropdown using xsl

From: "David Carnes" <davidc@----------------.--->
To: NULL
Date: 8/4/2004 10:38:00 AM
Kiran:
I highly recommend that you download Xselerator; it has a built in wizard
for <select> controls.
www.marrowsoft.com

I had to tweak this a little, but this is pretty much what the wizard
created:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method='html' indent='yes' omit-xml-declaration='yes' />
  <xsl:template match="Roles">
    <select name="selRoles" size="3" style="WIDTH: 278px; HEIGHT: 50px"
multiple="true">
      <xsl:for-each select="Role">
        <option>
          <xsl:attribute name="value"><xsl:value-of
select="@Roleid"/></xsl:attribute>
          <xsl:value-of select="text()"/>
        </option>
      </xsl:for-each>
    </select>
  </xsl:template>
</xsl:stylesheet

This also works if I replace <option> with <xsl:element name="option">, as
you had in your XSL.  My guess is that <xsl:for-each
select="DSUser/Roles/Role"> doesn't match anything in the XML you posted.
You don't need to have your pattern match start at the beginning of the
document; you've matched <Roles> to get into the template, so that is the
context node.  <xsl:for-each select="./Role"> is probably more accurate, as
the period basically says, "Start at the context node and get all children
named 'Role.'"  Ah wait, found a passage in Michael Kay's "XSLT Programmer
Reference."  "./Role" and "Role" are equivalent; some people use the .
operator for clarity at the start of a relative path. (page 357).

Ciao,
Dave


"Kiran" <Kiran@d...> wrote in message
news:5D90FEF6-F2F0-4F93-B8F6-2070518620A1@m......
>
> I am a newbie to XSL, so please advise me on something:
>
> I have this XML -
>
> <root>
> <emp>....</emp>
> <Roles>
> <Role Roleid='15'>One</Role>
> <Role Roleid='12'>Two</Role>
> ..
> </Roles>
> </root>
>
>
> - that I am transforming using an XSL that displays the information on an
ASP page. I have been able to display the <emp> values properly on <td>'s
and when I try to put the roles on a Combo box using -
>
>
> <xsl:template name="RoleList" match="Roles">
> test
> <select name="selRoles" size="3" style="WIDTH: 278px; HEIGHT: 50px"
multiple="true">
> <xsl:for-each select="DSUser/Roles/Role">
> <xsl:element name="option">
> <xsl:attribute name="value"><xsl:value-of
select="@RoleID"/></xsl:attribute>
> <xsl:value-of select="Role"/>
> </xsl:element>
> </xsl:for-each>
> </select>
> </xsl:template>
>
>
> The combo box never gets populated for each row of tranformed <emp>. Any
help would be appreciated.
>
> Kiran




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent