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

Re: Multiple template rules, in different files, match

Subject: Re: Multiple template rules, in different files, matching same element ... how to invoke a template rule in a specific XSLT file?
From: "Christophe Marchand cmarchand@xxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 11 Apr 2019 16:05:03 -0000
Re:  Multiple template rules
We do not duplicate code. Never. So we re-use a lot existing code. And so, we have a lot of xsl:import.

Each xsl module has it's own "main" mode, and a template match='/' with no mode that apply-templates mode="own-main-mode"

The "master" xsl has also a template match="/" with no mode, which has the top-most priority, and overwrites all other.

When we want to specify a specific call, we apply-templates with the desired mode. We didn't find a better way to do it.

Best,
Christophe

Le 11/04/2019 C 15:47, Costello, Roger L. costello@xxxxxxxxx a C)critB :
Hi Folks,

I have multiple template rules that match on airport/row and the template rules all have the same mode:

<xsl:template match="airport/row" mode="A-to-B">
     ...
</xsl:template>

However, they are located within different XSLT files, in different folders.

I have a master XSLT file that includes the XSLT files:

<xsl:include href="../airport-identifier/transform-identifier.xsl"/>
<xsl:include href="../airport-location/transform-location.xsl"/>
<xsl:include href="../airport-magnetic-variation/transform-magnetic-variation.xsl"/>

In this master XSLT file I have a template rule that wants to (for example) invoke the template rule for airport/row that is in airport-location/transform-location.xsl

How do you recommend doing this?

I could customize the mode in each XSLT file, e.g.,

In airport-identifier/transform-identifier.xsl do this:
<xsl:template match="airport/row" mode="identifier-A-to-B">

In airport-location/transform-location.xsl do this:
<xsl:template match="airport/row" mode="location-A-to-B ">

In airport-magnetic-variation/transform-magnetic-variation.xsl do this:
<xsl:template match="airport/row" mode="magnetic-variation-A-to-B ">

And then invoke the desired template rule by specifying the appropriate mode, e.g.,

<xsl:apply-templates select="airport/row" mode="location-A-to-B" />

That approach seems awful.

Is there a better approach?

/Roger

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.