simulating conditional <xsl:include> behavior?

Subject: simulating conditional <xsl:include> behavior?
From: Mike Brown <mbrown@xxxxxxxxxxxxx>
Date: Wed, 3 Nov 1999 01:07:03 -0700
I am wondering if there is an obvious solution that I'm overlooking here,
perhaps involving XML parameter or general entities or something.

What I would like to do is the equivalent of wrapping <xsl:include> in an
<xsl:if> or <xsl:for-each>. I want to pull into my stylesheet certain XSLT
templates only when certain conditions are true -- namely, the presence of
certain data in a source document. The goal is to cut down on the overhead
of parsing myriad XSLT documents before the meat of the XSLT processing can
begin.

sample XML fragment that lists all possible templates:
<myXML>
    <templates>
        <template name="foo" URI="bar.xsl">
        <template name="baz" URI="maz.xsl">
        <template name="hello" URI="world.xsl">
    </templates>
    <data>
        <foo>process me</foo>
        <baz>process me</baz>
    </data>
</myXML>

sample XSL fragment illustrating the effect I'd like to achieve:
<xsl:for-each select="/myXML/data/*">
    <xsl:include href="{/myXML/template[@name=.]/@URI}"/>
</xsl:for-each>

Of course, the href attribute on <xsl:include> is not an attribute value
template and <xsl:for-each> isn't allowed at the top level, so this isn't
the right approach. Any suggestions appreciated. I'm using XT.

-Mike


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread