[xsl] rewriting xslt 1 to xslt 2.0

Subject: [xsl] rewriting xslt 1 to xslt 2.0
From: "Bryan Rasmussen" <bry@xxxxxxxxxx>
Date: Mon, 28 Jan 2002 18:06:36 +0100
I have some stylesheets I wrote a long time ago, about 7 months I guess, and
I want to update them now to xslt 2.0(it was a stylesheet for generating
further stylesheets) the whole thing is quite gnarly in the code so I won't
reproduce it here. below is the current part I'm working on(have already
gotten rid of nodeset and am just doing that part the xslt 2.0 way)
this is a stylesheet responsible for putting out the templates that allow
people to switch between different styles on the site, the named stylesheet
referred to below: langstring
is for putting in the proper language text for the link. so anyway I want
some input on things I could improve, especially in an xslt 2.0 way, note
that not all variables are shown here(most of them are just string values
anyway).



<xsl:param name="siblings">
<stil for="def" type="1">dyn</stil>
<stil for="def" type="2">plain</stil>
<stil for="dyn" type="1">def</stil>
<stil for="dyn" type="2">plain</stil>
<stil for="plain" type="1">def</stil>
<stil for="plain" type="2">dyn</stil>
</xsl:param>
<xsl:variable name="stilnum" select="number('2')"/>

<xsl:template name="changeStyles">
	<xsl:variable name="br_type" select="@browse"/>
	<xsl:variable name="st_type" select="@style"/>
  <tempxsl:template match="change_style">
	<xsl:call-template name="styleif">
		<xsl:with-param name="for" select="$st_type"/>
		<xsl:with-param name="br" select="$br_type"/>
		<xsl:with-param name="type" select="1"/>
	</xsl:call-template>
    <tempxsl:apply-templates/>
   </tempxsl:template>
</xsl:template>


<xsl:template name="styleif">
	<xsl:param name="for"/>
	<xsl:param name="br"/>
	<xsl:param name="type"/>
	<xsl:variable name="stiltext" select="$siblings/stil[@for=$for and
@type=$type]"/>

<br/>
<a>
 <tempxsl:attribute name="href"><xsl:value-of
select="$br"/>assembler.asp?xmlsrc=&mspgl;
 <tempxsl:value-of select="$title"/>&amp;st=<xsl:value-of
select="$br"/><xsl:value-of select="$stiltext"/>     	</tempxsl:attribute>
		<xsl:call-template name="langstring">
			<xsl:with-param name="trans2" select="concat($stiltext,'_style')"/>
		</xsl:call-template>
</a>


	<xsl:if test="$stilnum &gt; $type">
		<xsl:call-template name="styleif">
			<xsl:with-param name="for" select="$for"/>
			<xsl:with-param name="br" select="$br"/>
			<xsl:with-param name="type" select="$type + 1"/>
		</xsl:call-template>
	</xsl:if>
</xsl:template>


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


Current Thread