[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] xsl:apply-templates and modes ("default" mode?)


Subject: [xsl] xsl:apply-templates and modes ("default" mode?)
From: Clay Leeds <cleeds@xxxxxxxxxx>
Date: Thu, 15 May 2003 10:49:08 -0700

I have a template I made some time ago which *always* outputs 4 lines. However, on a separate page (in a separate template), I want to output only those lines that have data. "mode=" appears to be ideal for this, but I'd rather not *require* a mode (without a mode, it "defaults" to one version; if a mode is specified, it uses that mode). I'd like to have it use the current "always output 4 lines" version unless mode is specified.

Is this possible? If I have one xsl:template with a mode, do I have to always specify the two types of modes?

I'm hoping to be able to keep the current standard/default method, so I don't have to go and change all of the documents which are currently using that system.

Here's my XML:

<ICD9S>
  <ICD9LINE>
    <ICD9>847.1</ICD9>
    <ICD9DESC>IMPORTANT INFORMATION ABOUT 847.1</ICD9DESC>
  </ICD9LINE>
  <ICD9LINE>
    <ICD9>847.2</ICD9>
    <ICD9DESC>IMPORTANT INFORMATION ABOUT 847.2</ICD9DESC>
  </ICD9LINE>
  <ICD9LINE>
    <ICD9>847.3</ICD9>
    <ICD9DESC>IMPORTANT INFORMATION ABOUT 847.3</ICD9DESC>
  </ICD9LINE>
  <ICD9LINE>
    <ICD9/>
    <ICD9DESC/>
  </ICD9LINE>
</ICD9S>

And my XSL-FO:

<xsl:template match="ICD9S">
<fo:block>
<fo:table border="0pt" table-layout="fixed">
<fo:table-column column-width="1.9cm"/>
<fo:table-column column-width="18.1cm"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell text-align="right">
<fo:block font-weight="bold" keep-with-next.within-page="always">
ICD9:
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:table border="0pt" table-layout="fixed" margin-top="4pt">
<fo:table-column column-width="1.3cm"/>
<fo:table-column column-width="16.8cm"/>
<fo:table-body>
<xsl:for-each select="ICD9LINE">
<fo:table-row>
<xsl:attribute name="background-color"><xsl:choose><xsl:when test="(position() mod 2) = 0"><xsl:value-of select="$varAccentBGColor"/></xsl:when><xsl:otherwise><xsl:value-of select="$varNormalBGColor"/></xsl:otherwise></xsl:choose></xsl:attribute>
<fo:table-cell>
<fo:block keep-with-next.within-page="always">
<xsl:value-of select="ICD9"/>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block padding-left="6pt" keep-with-next.within-page="always">
<fo:inline font-size="4pt">&#160;</fo:inline>
<xsl:value-of select="ICD9DESC"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
</fo:table>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
</xsl:template>


I'd like to add this underneath, if possible:

<xsl:template match="ICD9S" mode="drg">
<fo:block>
<fo:table border="0pt" table-layout="fixed">
<fo:table-column column-width="1.9cm"/>
<fo:table-column column-width="18.1cm"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell text-align="right">
<fo:block font-weight="bold" keep-with-next.within-page="always">
ICD9:
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:table border="0pt" table-layout="fixed" margin-top="4pt">
<fo:table-column column-width="1.3cm"/>
<fo:table-column column-width="16.8cm"/>
<fo:table-body>
<xsl:for-each select="ICD9LINE">
<xsl:choose>
<xsl:when test=".!=''">
<fo:table-row>
<xsl:attribute name="background-color"><xsl:choose><xsl:when test="(position() mod 2) = 0"><xsl:value-of select="$varAccentBGColor"/> </xsl:when> <xsl:otherwise><xsl:value-of select="$varNormalBGColor"/></xsl:otherwise></xsl:choose></xsl:attribute>
<fo:table-cell>
<fo:block keep-with-next.within-page="always">
<xsl:value-of select="ICD9"/>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block padding-left="6pt" keep-with-next.within-page="always">
<fo:inline font-size="4pt">&#160;</fo:inline>
<xsl:value-of select="ICD9DESC"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:when>
<xsl:otherwise>
<fo:table-row>
<fo:table-cell number-columns-spanned="2">
<fo:block keep-with-next.within-page="always">
&#160;
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</fo:table-body>
</fo:table>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
</xsl:template>


Does anyone have a better idea?
--
Clay Leeds - cleeds@xxxxxxxxxx
Web Developer - Medata, Inc. - http://www.medata.com
PGP Public Key: https://mail.medata.com/pgp/cleeds.asc


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




Current Thread