|
Subject: Re: [xsl] displaying sql results in dropdown menus From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Thu, 19 Aug 2004 09:55:46 +0100 |
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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] displaying sql results in dro, Matt Rich | Thread | [xsl] Passing parameter into xsl:fo, Ade Odusote |
| Re: [xsl] Dynamicly Generate a appl, Jeni Tennison | Date | RE: [xsl] displaying sql results in, Andrew Welch |
| Month |