Re: [xsl] Calling a different stylesheet based upon XML tag?

Subject: Re: [xsl] Calling a different stylesheet based upon XML tag?
From: Robert Koberg <rob@xxxxxxxxxx>
Date: Mon, 25 Oct 2004 12:18:28 -0700
Wilde Rebecca L SSgt HQ SSG/STS wrote:
Hello,

I was kindly directed here to ask my questions =)

I would like to be able to create multiple XSLT stylesheets which could
contain the same template names within them.  I would then like to be
able to create one XSLT stylesheet as a driver, to look at incoming XML
and based upon a key tag in it, pass it through the appropriate XSLT
stylesheet.

For example:
I have order.xslt and bill.xslt.  Both contain a template named Address.
Sending in a set of Order tags to my XSLT driver would transform it
through the order.xslt to a shipping label, whereas sending in a set of
Bill tags to my XSLT driver would transform through the bill.xslt to an
invoice.

This is pretty easy in XSL. You just need to apply templates on the source and catch the elements with template matches. You could do something like:



<!-- router.xsl --> <xsl:import href="order.xsl"/> <xsl:import href="bill.xsl"/>

<xsl:template match="/rootElem">
  <xl:apply-templates/>
</xsl:template>

<!-- order.xsl -->
<xsl:template match="Order">
... do order processing...
</xsl:template>

<!-- bill.xsl -->
<xsl:template match="Bill">
... do bill processing...
</xsl:template>

best,
-Rob



What commands or usage do I need to be looking at to create this driver? I've looked at import and include and I'm not completely sure that the same template names would not cause one to have priority over the other.

Thank you,
Becky

Current Thread