Re: [xsl] Different conditional outputs in same Stylesheet or calling another stylesheet (version 1.0, Xalan)

Subject: Re: [xsl] Different conditional outputs in same Stylesheet or calling another stylesheet (version 1.0, Xalan)
From: Florent Georges <lists@xxxxxxxxxxxx>
Date: Wed, 27 Feb 2008 11:59:08 +0100 (CET)
Pankaj Chaturvedi wrote:

  Hi

> I am writing a stylesheets for different journal
> (basically for print), wherein the order of authors,
> titles etc varies (<ref-book> here)depending upon the
> <journalcode>.

  Depending on the amount of differences between the various
versions, you might want to use on of the following (from
less to more differences).

  1/ For simple differences between the various formats to
generate, you can use different template rules:

    <xsl:template match="journalcode = 'A'">
       <something>
          <xsl:apply-templates/>
       </something>
    </xsl:template>

    <xsl:template match="journalcode = 'B'">
       <something-else>
          <xsl:apply-templates/>
       </something-else>
    </xsl:template>

  2/ If a lot of the processing will depend on that value,
you can use different modes, one per case:

    <xsl:template match="journalcode = 'A'">
       <xsl:apply-templates select="." mode="in-a"/>
    </xsl:template>

    <xsl:template match="journalcode = 'B'">
       <xsl:apply-templates select="." mode="in-b"/>
    </xsl:template>

    <xsl:template match="journalcode" mode="in-a">
       ...
    </xsl:template>

    <xsl:template match="..." mode="in-a">
       ...
    </xsl:template>

    <xsl:template match="journalcode" mode="in-b">
       ...
    </xsl:template>

    <xsl:template match="..." mode="in-b">
       ...
    </xsl:template>

  3/ You can put each mode in a separate stylesheet module
for editorial clarity.

  4/ If you know which case you want to use before launching
the transform, you can make a different module for each
case, containing what is specific for this case, and each
specific module importing common modules.  Then you use
the appropriate module for each transform.

  Regards,

--drkm























      _____________________________________________________________________________ 
Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail http://mail.yahoo.fr

Current Thread