xsl-list
[Top] [All Lists]

Re: [xsl] Inconsistency in descendant:: expressions?

2013-08-04 04:05:50
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.

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.


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


--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>