[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: [saxon] template match dependent on parent

Subject: Re: [saxon] template match dependent on parent
From: Ihe Onwuka <ihe.onwuka@xxxxxxxxx>
Date: Fri, 31 Jan 2014 04:41:22 +0000
 Re: [saxon] template match dependent on parent
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.Lizzi@xxxxxxxxxxxxxxxxxxxx> 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.onwuka@xxxxxxxxx]
> 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@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/saxon-help

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.