[xsl] numbering empty entities

Subject: [xsl] numbering empty entities
From: Michael Schäfer <MSchaefer@xxxxxxxxxxxx>
Date: Fri, 6 Jul 2001 13:20:22 +0200
I 've got an XML-doc

<ROOT>
	<TABLE1>
		<EL>A</EL>
	</TABLE1>
	<TABLE1>
		<EL>B</EL>
	</TABLE1>
	<TABLE1/>
	<TABLE1>
		<EL>D</EL>
	</TABLE1>
	<TABLE1>
		<EL>E</EL>
	</TABLE1>
	<TABLE1>
		<EL>F</EL>
	</TABLE1>
</ROOT>

and want to transform it into

<?xml version="1.0" encoding="utf-8"?>
<ROOT>
	<TABLE1>
		<TABLE1_LNR>1</TABLE1_LNR>
		<EL>A</EL>
	</TABLE1>
	<TABLE1>
		<TABLE1_LNR>2</TABLE1_LNR>
		<EL>B</EL>
	</TABLE1>
	<TABLE1>
		<TABLE1_LNR>3</TABLE1_LNR>
	</TABLE1>
	<TABLE1>
		<TABLE1_LNR>4</TABLE1_LNR>
		<EL>D</EL>
	</TABLE1>
	<TABLE1>
		<TABLE1_LNR>5</TABLE1_LNR>
		<EL>E</EL>
	</TABLE1>
	<TABLE1>
		<TABLE1_LNR>6</TABLE1_LNR>
		<EL>F</EL>
	</TABLE1>
</ROOT>

You see, the task is to add the counting to every <TABLE1>-entity, also
to the empy entity

My stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:template match="*">
	<xsl:copy>
		<xsl:apply-templates select="*"/>
	</xsl:copy>
</xsl:template>

<xsl:template match="TABLE1/*[1]">
	<xsl:element name="TABLE1_LNR">
		<xsl:number count="TABLE1" level="single"/>
	</xsl:element>
	<xsl:copy>
		<xsl:apply-templates select="node()"/>
	</xsl:copy>
</xsl:template>
</xsl:stylesheet>

The stylesheet doesn't add the number to the empty entity. The reason
is, that the pattern "TABLE1/*[1]" doesn't match. But how can I resolve
the task?

Greetings
Michael

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


Current Thread