xsl-list
[Top] [All Lists]

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

2010-01-17 19:20:37
At 2010-01-18 01:47 +0100, cvergara(_at_)zedat(_dot_)fu-berlin(_dot_)de 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[(_at_)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[(_at_)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(_at_)CraneSoftwrights(_dot_)com
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--