[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Inconsistency in descendant:: expressions?

Subject: Re: Inconsistency in descendant:: expressions?
From: Peter West <lists@xxxxxxxxx>
Date: Sun, 4 Aug 2013 20:36:11 +1000
Re:  Inconsistency in descendant:: expressions?
See below.

Peter West

"Ask and it will be given you; seek, and you will find; knock, and it will be
opened to you."

On 04/08/2013, at 7:05 PM, Martin Honnen <Martin.Honnen@xxxxxx> wrote:

> Peter West wrote:
>> I'm using Oxygen 15.0 with Saxon PE 9.5.0.2 XSLT 2.
>>
>> My XSLT is rusty, and I was struggling with the expression of particular
descendant expression. After a number of botched attempts, I cam up with two
versions that seemed to work. (Yes, I will use the ancestor:: axis, but I want
to know what is happening here.)
>>
>> The following code operates on an xhtml document.
>
> It would help if you posted a minimal but complete document allowing us to
reproduce the problem.
>
>
>> 1)  <xsl:variable name="table-node" select="//*:table[//*:tr[count(*:td) =
3]][1]"/>
>
> Are you sure that you want
>  //*:tr
> inside of the predicate and not
>  .//*:tr
> ?
> Your current versions looks at all *:tr elements in the document, not at the
*:tr descendants of the *:table element you are applying the predicate to.

yes, I want .//*:tr.  It worked because there is only one table in the file I
was using.  I've fixed that, but it that doesn't change the result.
>
>> 2)  <xsl:variable name="table-ancestors"
select="//*[descendant::node()=$table-node]"/>
>
> You compare the string value of a table element to other nodes, is that what
you want? The ". is $foo" which checks node identity you have below in 3)
seems more meaningful to me.

Ok. The penny has dropped. The select is supposed to find all nodes from the
root that have a particular <table> node as a descendant. In the case above,
the node() string value is compared to the string value of the <table> node;
that node matches. However, the string value of the <tbody> node also matches,
so the <table> has such a descendant,

Thanks!


>
>
>> 3)  <xsl:variable name="table-parents" select="//*[descendant::node()[. is
$table-node]]"/>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.