RE: [xsl] problem with node-set pattern

Subject: RE: [xsl] problem with node-set pattern
From: "Michael Kay" <mhkay@xxxxxxxxxxxx>
Date: Fri, 6 Jul 2001 13:56:22 +0100
> In my XML-doc I have several entities, which I want to number.

Actually, they are called elements...
> Then I thought of using
>
> <xsl:template match="TABLE1/*[1] | TABLE2/*[1]">
> 	<xsl:element name="{name(..)}_LNR">
> 		<xsl:number count="{name(..)}" level="single"/>
> 	</xsl:element>
> 	<xsl:copy>
> 		<xsl:apply-templates select="node()"/>
> 	</xsl:copy>
> </xsl:template>
>
> But the Processor (Infoteria) says:invalid pattern in count attribute.

Quote right too. You can't have curly braces in an attribute where an
expression or pattern is required.

One solution is not to use xsl:number at all. Very often its easier and more
flexible to use something like

<xsl:value-of select="count(../preceding-sibling::*[name()=$name])"/>

Another approach is to make the parent node current before calling
<xsl:number>. For example

<xsl:template match="*" mode="number">
  <xsl:number/>
</xsl:template>

and then
<xsl:apply-templates select=".." mode="number"/>
in the place where you currently call <xsl:number/>

Mike Kay
Software AG
>
> What can I do?
>
> Mit freundlichen Grüßen
> Michael Schäfer
>
> ---------------------------------------------------------------
> Dipl.-Ing. Michael Schäfer
> e-business
>
> Pfeil GmbH
> Obertorstr. 4-6
> 66111 Saarbrücken
>
> Tel.: 06 81/3 79 85-30
> Fax: 06 81/3 79 85-13
>
> e-Mail: mschaefer@xxxxxxxxxxxx
> Internet: www.pfeilgmbh.de
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


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


Current Thread