Re: [xsl] Match nodes searching for attributes in children

Subject: Re: [xsl] Match nodes searching for attributes in children
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Sun, 17 Jan 2010 20:10:15 -0500
At 2010-01-18 01:47 +0100, cvergara@xxxxxxxxxxxxxxxxxx wrote:
I want to match a node A that has a child B with an @attr = 1. I tried
this, but it didn't work:

<xsl:template match="//A[B/@attr = 1]">

also this didn't work:

<xsl:template match="//A[B[@attr = 1]]">

Does anyone know how to do it?

One doesn't typically use the "//", but it doesn't make it wrong.


Your expressions look valid to me, though I would have written them as:

<xsl:template match="A[B/@attr = 1]">

or

<xsl:template match="A[B[@attr = 1]]">

You say "it didn't work" but you don't say how or why you think so. I suspect you have something else wrong in your stylesheet.

I hope this helps.

. . . . . . . . . . Ken


-- UBL and Code List training: Copenhagen, Denmark 2010-02-08/10 XSLT/XQuery/XPath training after http://XMLPrague.cz 2010-03-15/19 XSLT/XQuery/XPath training: San Carlos, California 2010-04-26/30 Vote for your XML training: http://www.CraneSoftwrights.com/s/i/ Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18 Video overview: http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18 G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal

Current Thread