No. It just moves the test from the match pattern to inside the
template rule and it's more verbose.
Giving it further thought I think this is a case for a pull processing.
<xsl:template match="onTheParentOFA">
<xsl:if test="@attr eq 'datasource1'">
<xsl:for-each select="a">
etc
</xsl:for-each>
</xsl:if>
<xsl:if test="@attr eq 'datasource2'">
<xsl:for-each select="a">
etc
</xsl:for-each>
</xsl:if>
</xsl:template>
and the test for the datasource only gets done once.
Apologies I just realised I sent this to the wrong mailing list.
Correcting that now.
On Fri, Jan 31, 2014 at 4:20 AM, Lizzi, Vincent
<Vincent(_dot_)Lizzi(_at_)taylorandfrancis(_dot_)com> wrote:
Would this be more efficient?
<xsl:template match="a[parent::*/@attr]">
<xsl:choose>
<xsl:when test="contains(parent::*/@attr,'datasource1')">
blah
blah
</xsl:when>
<xsl:when test="contains(parent::*/@attr,'datasource2')">
blah
blah
</xsl:when>
<xsl:otherwise>
blah
blah
</xsl:otherwise>
</xsl:choose>
</xsl:template>
-----Original Message-----
From: Ihe Onwuka [mailto:ihe(_dot_)onwuka(_at_)gmail(_dot_)com]
Sent: Thursday, January 30, 2014 11:13 PM
To: Mailing list for the SAXON XSLT and XQuery processor
Subject: [saxon] template match dependent on parent
So I want to match on <a> elements.
What I want to do in the template rule however is dependent on an attribute
in the parent of the <a> element that conveys the data source.
I could do
<xsl:template match="a[contains(../@attr,'datasource1')]">
blah
blah
</xsl:template>
<xsl:template match="a[contains(../@attr,'datasource2'])">
blah
blah
</xsl:template>
and it should work, but that means I am testing the contains condition on
every iteration of <a> element but it will return the same value for every
iteration and hence is unsatisfactory.
Any advances on this.
------------------------------------------------------------------------------
WatchGuard Dimension instantly turns raw network data into actionable
security intelligence. It gives you real-time visual feedback on key security
issues and trends. Skip the complicated setup - simply import a virtual
appliance and go from zero to informed in seconds.
http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help(_at_)lists(_dot_)sourceforge(_dot_)net
https://lists.sourceforge.net/lists/listinfo/saxon-help
--~------------------------------------------------------------------
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>
--~--