How to include different XSLT files on the fly based on some criteria?

M

Mohit

Hi Friends

I have to call 1 of the 2 child XSLT files from the Main XSLT file
based on some criteria. I want one child XSLT file will be executed by
version 1 of XSLT processor and the other by version 2 of XSLT
processor based on some condition.

Q) How and where shall I write logic or import desirable XSLT on the
Fly ?
Q) When we call AAA.XSLT then it will be processed by XSLT Processor 1
and when we call BBB.XSLT,it will be called by XSLT processor 2. (This
is what I want to happen). Is this statement correct? Is it possible?

---Main.XSLT-----
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- This functionality is not supported. -->
<xsl:choose>
<xsl:when test = "X = AAA">
<xsl:include href=".\AAA.xslt"/>
</xsl:when>
<xsl:when test = "X = BBB">
<xsl:include href=".\BBB.xslt"/>
</xsl:when>
</xsl:choose>
</xsl:stylesheet>

---AAA.XSLT----------
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<!----some code here for version 1 of xslt---->
</xsl:template>
</xsl:stylesheet>


---BBB.XSLT-----------
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<!------some code here for version 2 of xslt---->
</xsl:template>
</xsl:stylesheet>


Thanks
Mohit
(e-mail address removed)
 
M

Martin Honnen

Mohit said:
I have to call 1 of the 2 child XSLT files from the Main XSLT file
based on some criteria. I want one child XSLT file will be executed by
version 1 of XSLT processor and the other by version 2 of XSLT
processor based on some condition.

Q) How and where shall I write logic or import desirable XSLT on the
Fly ?
Q) When we call AAA.XSLT then it will be processed by XSLT Processor 1
and when we call BBB.XSLT,it will be called by XSLT processor 2. (This
is what I want to happen). Is this statement correct? Is it possible?

---Main.XSLT-----
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- This functionality is not supported. -->
<xsl:choose>
<xsl:when test = "X = AAA">
<xsl:include href=".\AAA.xslt"/>
</xsl:when>
<xsl:when test = "X = BBB">
<xsl:include href=".\BBB.xslt"/>
</xsl:when>
</xsl:choose>
</xsl:stylesheet>

---AAA.XSLT----------
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<!----some code here for version 1 of xslt---->
</xsl:template>
</xsl:stylesheet>


---BBB.XSLT-----------
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<!------some code here for version 2 of xslt---->
</xsl:template>
</xsl:stylesheet>

As for testing features before you use them you could use the XSLT
functions element-availabe and function-available and xsl:fallback.
However I don't see a way to conditionally include a stylesheet.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top