[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: displaying sql results in dropdown menus

Subject: Re: displaying sql results in dropdown menus
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Thu, 19 Aug 2004 09:55:46 +0100
substring after sql
Hi Matt,

> // I catch the attributes' ids in xsl variables
>
>      <xsl:variable name="idattr1" select="../../idattr[1]"/>
>      <xsl:variable name="idattr2" select="../../idattr[2]"/>

The variable $idattr1 contains the <idattr> element with the value
'sql:id_collection'. Similarly, the variable $idattr2 contains the
<idattr> element with the value 'sql:libelle_collection'.

> // And I try to get their values in a dropdown list
>
>              <xsl:for-each select="sql:row">
>                  <option  value= "$idattr1">
>                 <xsl:value-of select="$idattr2"/>
>                </option>
>               </xsl:for-each>

The value attribute is set to the literal string "$idattr1" (not the
value of the $idattr1 variable -- you need to use attribute value
templates for that). The value of $idattr2 is
"sql:libelle_collection".

What you're after are the values of the <id_collection> and
<libelle_collection> elements within the current <sql:row> element.
The name of the first element (for the value attribute) is held in the
$idattr1 variable, after the colon:

  substring-after($idattr1, ':')

You need to locate the child of the current <sql:row> element whose
local name is the same as this substring:

  *[local-name(.) = substring-after($idattr1, ':')]

(Namespace awareness is more fiddly; do you really need it or can you
guarantee that all the children of the <sql:row> elements are in the
SQL namespace?)

So you need:

  <xsl:for-each select="sql:row">
    <select value="{*[local-name(.) =
                      substring-after($idattr1,':')]}">
      <xsl:value-of select="*[local-name(.) =
                              substring-after($idattr2, ':')]" />
    </select>
  </xsl:for-each>

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.