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

Re: XSL Java Extension problem.

Subject: Re: XSL Java Extension problem.
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Thu, 1 Nov 2001 16:38:11 +0000
xsl java extension
Hi Sudhir,

> I found that all my stylesheets were same but differed in the
> columns (in the XML) I was processing, for example I was doing
> <xsl:apply-templates select="td[4] | td[5] | td[6] | td[7]"/>
> in one stylesheet vs
> <xsl:apply-templates select="td[2] | td[7] | td[8]"/>
> in the other.
>
> Is there any other way to have a generic stylesheet which will
> accept the column values as parameters?

Yes. You could pass them in as a string value:

  '4:5:6:7:'
  or
  '2:7:8:'

Assuming this was the value of the $columns parameter for the
stylesheet, you could then count how many columns your table needed by
counting how many ':'s the string contained with:

  string-length(translate($columns, '0123456789', ''))

And you could work through the numbers in the list using recursion,
with something like:

<xsl:template name="processColumns">
  <xsl:param name="columns" select="$columns" />
  
  <xsl:variable name="columnIndex"
                select="substring-before($columns, ':')" />
  <xsl:variable name="remainingColumns"
                select="substring-after($columns, ':')" />

  <xsl:apply-templates select="td[number($columnIndex)]" />

  <xsl:if test="$remainingColumns">
    <xsl:call-template name="processColumns">
      <xsl:with-param name="columns" select="$remainingColumns" />
    </xsl:call-template>
  </xsl:if>
</xsl:template>

Alternatively, you could have one stylesheet that held all the common
code, and import that into individual stylesheets that focus on
different columns.

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 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.