This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Can you pass a parameter from a stylesheet to the resultingHTML file?


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@vikingfreight.com 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]