Subject: RE: template match : node-set paring through multiple-axis relationships
From: Américo Albuquerque <melinor@xxxxxxx>
Date: Tue, 3 Jun 2003 21:54:26 +0100
|
Hi.
> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of
> Jonathan Sprinkle
> Sent: Tuesday, June 03, 2003 6:35 PM
> To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
> Subject: RE: 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[@role='src']/@target"/>
<xsl:variable name="dst" select="c1[@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')[@id=$src][key('Bs','B')[@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
|