Re: [xsl] Problem with Xpath

Subject: Re: [xsl] Problem with Xpath
From: "CyberSpace Industries 2000 Inc." <csi2000@xxxxxxxxxxxxxxx>
Date: Wed, 13 Dec 2006 13:52:37 -0500
My first guess is that the following statement is always false
<xsl:if test="//info/company=$company and

since there is no children of info named company or product. Did you mean comp and prod?

If you are getting only the first of a set of nodes - check your other templates to make sure you aren't using a "value-of" on a set of nodes... in which case all other nodes other than the first (in document order) are ignored.

CyberSpace Industries 2000 Inc.
XML Training and Consulting

----- Original Message ----- From: "ms" <mina_hurray@xxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Wednesday, December 13, 2006 1:39 PM
Subject: [xsl] Problem with Xpath

Hi all:

I am having issues with Xpath.

My xml looks like this:


<para>First level</para>
<para>Second level .</para>
<para>Second level</para>
<para>Third level</para>

Now, I have logic in my style sheet which says that
only if element <l1> contains element <info>, then
if <comp> and <prod> values match the values being
passed to the style sheet through two other parameters
<company> and <product> , then display l1 , otherwise
do not display l1.

The XSLT is :

<xsl:template match="l1"> <xsl:choose> <xsl:when test="//info"> <xsl:if test="//info/company=$company and //info/product=$product"> <fo:list-block> <fo:list-item> <fo:list-item-label> <fo:block> <xsl:number format="1"/> </fo:block> </fo:list-item-label> <fo:list-item-body> <fo:block> <xsl:apply-templates/> </fo:block> </fo:list-item-body> </fo:list-item> </fo:list-block> </xsl:if> </xsl:when> <xsl:otherwise> <!-- Do something else--> </xsl:otherwise> </xsl:choose> </xsl:template>

So, if I have passed $company="KMart" and
$product="Shoes" on the style sheet, then the expected
output is:

1 First
2 Second

Instead, it matches only the company and product for
the first level and stops there. Can you please tell
me what is wrong with the xpath to company and product
on the style sheet?

Thank you in advance for your help.

Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.

Current Thread
  • [xsl] Problem with Xpath
    • ms - Wed, 13 Dec 2006 10:39:01 -0800 (PST)
      • CyberSpace Industries 2000 Inc. - Wed, 13 Dec 2006 13:52:37 -0500 <=
        • ms - Wed, 13 Dec 2006 11:02:32 -0800 (PST)
      • Michael Kay - Wed, 13 Dec 2006 21:48:58 -0000
      • <Possible follow-ups>
      • cknell - Wed, 13 Dec 2006 14:05:49 -0500
        • ms - Wed, 13 Dec 2006 11:45:34 -0800 (PST)