xsl-list
[Top] [All Lists]

[xsl] Multiple template rules, in different files, matching same element ... how to invoke a template rule in a specific XSLT file?

2019-04-11 08:47:52
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
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>