If you always want to favour the last one in document order, then it's
<xsl:apply-templates select="(./*/a)[last()]"/>
If you want to be more precise, then in XSLT 2.0 it's
<xsl:apply-templates select="(element1/a, element2/a)[last()]"/>
Regards,
Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay
-----Original Message-----
From: Szabo, Patrick (LNG-VIE)
[mailto:patrick(_dot_)szabo(_at_)lexisnexis(_dot_)at]
Sent: 19 October 2009 15:08
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] favor certain elements
Hi,
I´m using Saxon 9, and XSLT 2.0.
Source:
<root>
<element1>
<a>...</a>
<b>...</b>
</element1>
<element2>
<a>...</a>
<b>...</b>
<c>...</c>
</element2>
</root>
desired output:
<root>
<elementx>
<a>...</a>
<b>...</b>
<c>...</c>
</elementx>
</root>
What i want do do is to apply templates to the elements a, b, c.
The problem is that there is an element a in element1 and
another in element2. (same thing with element b) Is there a
way to favor certain elements ?!
If there is an element a in element1 and element2 i want to
use the a from element2 - if there isn´t i want to use the a
from element1.
I want to to the same thing with b but contrariwisely.
What i want is something like.
<xsl:apply-templates select="//a" fav="parent::element2"/>
I hope i explained the question sufficiently !
regards
Patrick Szabo
XSLT-Entwickler
Tel.: +43 (1) 534 52 - 1573
Fax: +43 (1) 534 52 - 146
Patrick(_dot_)Szabo(_at_)lexisnexis(_dot_)at
LexisNexis Verlag ARD Orac GmbH & Co KG
Marxergasse 25, 1030 Wien
FN 8333f, Handelsgericht Wien
http://www.lexisnexis.at/
--~------------------------------------------------------------------
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>
--~--
--~------------------------------------------------------------------
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>
--~--