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

RE: numbering empty entities

Subject: RE: numbering empty entities
From: Nielsen Anders Rolann <annie@xxxxxxxxxx>
Date: Tue, 10 Jul 2001 07:59:29 +0200
xsl number count empty
Hi MIchael!

What about this ?:

<?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 />
	</xsl:copy>
</xsl:template>

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

<xsl:template match="EL"> 
               <xsl:copy>
	               <xsl:apply-templates select="node()"/>
               </xsl:copy> 
</xsl:template> 
</xsl:stylesheet>

Regards
Anders Rolann, roe@xxxxxx





<?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>

-----Original Message-----
From: Michael Schäfer [mailto:MSchaefer@xxxxxxxxxxxx]
Sent: 6. juli 2001 13:20
To: XSL-Liste (E-Mail)
Subject:  numbering empty entities


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

 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.