xsl-list
[Top] [All Lists]

RE: template match : node-set paring through multiple-axis relationships

2003-06-03 13:54:26
Hi.

-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com 
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of 
Jonathan Sprinkle
Sent: Tuesday, June 03, 2003 6:35 PM
To: 'xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com'
Subject: RE: [xsl] template match : node-set paring through 
multiple-axis relationships


From message
(http://www.biglist.com/lists/xsl-list/archives/200305/msg01198.html)

Discouraged by XSL's limitations, I gave up doing it the nice 
way and hacked my own solution.  In case you care, here it 
is.  It is a pain in the bum, because now I have to create a 
bunch of variables, and do my own name mangling if I have two 
different things to do to a 'b' in two different contexts 
because XSL's namespace is intuitively different from 
conventional namespaces in C++.  However, it works, and I can 
generate it generically from a graphical transformation language.

For those who are in charge, and using this list to educate 
others on XSL to evangelise it to the world on XSL and its 
usage, I am disappointed that no one responded to my request, 
even to say "boy, that sure is a different problem".  :(


I try to but had some promlems in my email acount.

If I understand you correct you want to match a node 'b' based on two
conditions. It's easier if you select only those you want instead of
matching them

Try this:
 <!-- get all 'b's -->
 <xsl:key name="Bs" match="b" use="'B'"/>
 
 <xsl:template match="root">
  <doc>
  <xsl:apply-templates select="c"/>
  </doc>
 </xsl:template>
 
 <xsl:template match="b">
  <comment>Matched B...<xsl:value-of select="@id"/></comment>
 </xsl:template>

 <xsl:template match="c">
  <xsl:variable name="src" select="c1[(_at_)role='src']/@target"/>
  <xsl:variable name="dst" select="c1[(_at_)role='dst']/@target"/>
  <!-- select the 'b' nodes with id=$src and with parent 'a' that
doesn't have another 'a' as ancestor -->
  <xsl:apply-templates
select="key('Bs','B')[(_at_)id=$src][key('Bs','B')[(_at_)id=$dst]/parent::a[not(an
cestor::a)]]"/>
 </xsl:template>


Hope this helps you.
(...)



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



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