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

Discussion in 'XML' started by Mohit, Apr 19, 2004.

  1. Mohit

    Mohit Guest

    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
     
    Mohit, Apr 19, 2004
    #1
    1. Advertising

  2. Re: How to include different XSLT files on the fly based on somecriteria?

    Mohit wrote:

    > 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.
    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Apr 20, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stephajn Craig

    Highlight Text based on certain criteria

    Stephajn Craig, Jul 7, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    384
    Axel Dahmen
    Jul 8, 2003
  2. Replies:
    1
    Views:
    382
    mlimber
    Jul 21, 2006
  3. Andy Fish
    Replies:
    5
    Views:
    2,266
    Andy Fish
    Jul 31, 2007
  4. Micromanaged

    Form change based upon criteria selected?

    Micromanaged, Jul 2, 2004, in forum: ASP General
    Replies:
    3
    Views:
    134
    Bullschmidt
    Jul 5, 2004
  5. C White

    date based criteria

    C White, Dec 17, 2004, in forum: ASP General
    Replies:
    3
    Views:
    119
    C White
    Dec 17, 2004
Loading...

Share This Page