[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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

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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.