You can't use quotes with variables in predicates, unless the actual preference you're matching is '$preference'. No PHP fun here. Just take the quotes off and you should be fine.

<xsl:for-each select='/person:company/person:person[person:music-preference=$preference]'>

Curly braces are only used in result tree fragments (ie, output), never in regular XPath.

You might wish to check out the XSL list over at Mulberry Tech, it's geared toward answering general XSL questions, whereas this one is more for features and usage specific to Xalan.

http://www.mulberrytech.com/xsl/

Hope this helps.

Swiftpaw Foxyshadis, wildlife artist
[EMAIL PROTECTED] | http://foxyshadis.dyndns.org/


From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
CC: [EMAIL PROTECTED]
Subject: Fw: Problem Using an xsl:param in a Predicate
Date: Sun, 11 May 2003 21:10:02 -0400

As usual, the best place to get Xalan questions answered is on the
[EMAIL PROTECTED] list, as noted on our website.

You can read an archive at
http://marc.theaimsgroup.com/?l=xalan-j-users&r=1&w=2

- Shane
----- Forwarded by Shane Curcuru on 05/11/2003 09:03 PM -----

I have a named template called 'find-persons-with-preference' which
receives a single xsl:param with name = "preference", as shown below.
Note it contains several commented-out xsl:for-each statements which
I have used during testing.

<xsl:template name='find-persons-with-preference'>
                 <xsl:param name = "preference" />
                 <in-called-template pref='{$preference}' />
                 <xsl:for-each select =
'/person:company/person:person[person:music-preference="$preference"]' >

                 <!--<xsl:for-each select =
'/person:company/person:person[person:music-preference="{$preference}"]'
>-->
                 <!--<xsl:for-each select =
'/person:company/person:person[person:music-preference="folk"]' >-->
                 <!--<xsl:for-each select =
'/person:company/person:person' >-->
                                 <person-with-preference>
                                 <xsl:value-of select='@name' />
                                 </person-with-preference>
                 </xsl:for-each>
</xsl:template>

The predicate [person:music-preference="$preference"] returns no nodes.
Nor does the version of the predicate with curly braces,
[person:music-preference="{$preference}"].  However, the hard-coded
version of the predicate, [person:music-preference="folk"], DOES return
nodes.  Note this template begins by displaying the value of the
parameter.  For example, when passed the parameter "folk", this template
displays the line.

    <in-called-template pref="folk"></in-called-template>

When using the hard-coded version of the predicate, the following rows are
obtained:

    <in-called-template pref="folk"></in-called-template>
    <person-with-preference>Sammy</person-with-preference>
    <person-with-preference>Mika</person-with-preference>

When using $preference in the predicate, either with or without the curly
braces,
the following row is obtained instead:

    <in-called-template pref="folk"></in-called-template>

Is there something wrong with my non-hardcoded predicate?

Any help would be much appreciated.

Thank you.


_________________________________________________________________
MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. http://join.msn.com/?page=features/virus




Reply via email to