[xsl] template match : node-set paring through multiple-axis relationsh ips

Subject: [xsl] template match : node-set paring through multiple-axis relationsh ips
From: Jonathan Sprinkle <jonathan.sprinkle@xxxxxxxxxxxxxx>
Date: Thu, 29 May 2003 11:42:08 -0500
After about 4 hours of searching in the archives, I cannot find a similar
problem.  XSL-gurus: consider this problem your greatest nemesis, because as
far as XSL is concerned, it certainly is mine.  :)

I want to know this: can I use the xpath expression of a template match to
test id relationships at more than one point in the expression with the
context of the matching node?  For example...

I want to match a node 'b' based on two relationships to another node 'b' in
the file - relationship through containment and through association.  I want
to match this 'b' iff it is the source of an association AND the destination
of that association is a child of my grandparent (the association, in my
example, exists as IDREFs in a node neither an ancestor nor a descendent of
the src/dst objects).

The trouble comes that I can match if I am the source of this association,
and that the destination is a 'b' node.  AND I can match if my grandparent
has a child that is a 'b' node, BUT I have no way of guaranteeing that those
two 'b' nodes are identical.

While this may seem like an insignificant problem, consider the template
example, and the XML example that I have given below.  If I cannot guarantee
that the 'dst' and the "uncle" (for lack of a better term) are the same,
then I will match <b id="_11"/> AND <b id="_12"/>, although <b id="_11"/> is
the only node that I want.  Currently my template example will match both <b
id="_11"/> and <b id="_12"/> (at least, if I have stripped away all the
space right!).

Surely, someone out there has experience with this?  It would work well if I
could use the "current()" command, which is not permitted in a
match-pattern.  It is unacceptable to defer any testing to an "if" command
inside the template, because failure in the "if" command leaves me no
alternatives to match, and this 'b' node may require other processing if the
match is not made.

thanks is appreciated,

(examples below)

======== example of template ========

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
	<xsl:template match="/">
 <xsl:call-template name="WhatToDoWithMy_B_Now"/>
<xsl:template name="WhatToDoWithMy_B_Now">
		<xsl:comment>Matched B...<xsl:value-of

======== example XML document ========

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE root [
<!ELEMENT root ( a* | c* )*>
<!ELEMENT a (a* | b*)*>
<!ELEMENT c (c1*)>


		<b id="_10"/>
			<b id="_11"/>
			<b id="_12"/>
		<c1 role="src" target="_11"/>
		<c1 role="dst" target="_10"/>
		<c1 role="src" target="_12"/>
		<c1 role="dst" target="_11"/>

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread