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

Re: Can you pass a parameter from a stylesheet to the

Subject: Re: Can you pass a parameter from a stylesheet to the resultingHTML file?
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Sat, 01 Jun 2002 01:34:52 +0200
xsl xml transform xhtml ol
Hello Kathryn,

it's a bit difficult to see, what you are doing with your two stylesheets. In general you can do it in the following:

<xsl:template match="foo">
  <xsl:apply-templates select="bar">
    <xsl:with-param name="name-of-param" select="value-of-param"/>
  </xsl:apply-templates>
</xsl:template>

<xsl:template match="bar">
  <xsl:param name="name-of-param" select="default-value-of-param"/>
  <xsl:value-of select="$name-of-param"/>
</xsl:template>

If your stylesheet below runs on the XML below, you can do something like the following:

<xsl:template match="node() | @*">
  <xsl:copy>
    <xsl:apply-templates select="node() | @*"/>
  </xsl:copy>
</xsl:template>

<xsl:template match="ol">
  <ol start="{count(preceding::ol) + 1}">
    <xsl:apply-templates select="node() | @*"/>
  </ol>
</xsl:template>

Regards,

Joerg


Grant-Kathryn@xxxxxxxxxxxxxxxxx wrote:
Hi all,

I sure appreciate everyone's help!  The manual I'm working on is going well
because of it.

I have a more complicated question.  Part of my XHTML file contains a table,
simplified below:

<table>
  <tr>
	<td>
	   <ol>
		<li>item 1</li>
		<li>item 2</li>
		<li>item 3</li>
	   </ol>
	</td>
  </tr>

  <tr>
	<td>
	   <ol start="4">
		<li>item 4</li>
		<li>item 5</li>
		<li>item 6</li>
	   </ol>
	</td>
  </tr>
</table>

As you can see, I have a continuous list split across two cells.  Even if I
don't close the </ol> in the first cell, the numbering starts again at 1 in
the next cell unless I use <ol start="4">.

My question is this.  I have two different stylesheets transforming the same
XHTML file.  One stylesheet filters the XHTML file so the number of list
items is less; therefore, the <ol> start attribute needs to be different in
each transformed file.

I understand that I can declare a parameter in my XSL file thus: <xsl:param name="startnum" select="3"/>

But is there a way to pass that parameter to the <ol> tag's start attribute
in the transformed file?  I've checked my XSL books and searched on the web,
but I can't find a way to do this.

Below is the XSL file I'm using--it's pretty simple.

----------------------xsl file---------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xhtml="http://www.w3.org/1999/xhtml"
    version="1.0">

<xsl:output method="xml" encoding="UTF-8"/>
	<xsl:template match="node() | @*">
		<xsl:copy>
			<xsl:apply-templates select="node() | @*"/>
		</xsl:copy>
	</xsl:template>
</xsl:stylesheet>
--------------------end xsl file---------------------------

TIA,
Kathryn


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.