This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: numbering empty entities
- To: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] numbering empty entities
- From: Nielsen Anders Rolann <annie at wmdata dot com>
- Date: Tue, 10 Jul 2001 07:59:29 +0200
- Reply-To: xsl-list at lists dot mulberrytech dot com
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@sol.dk
<?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@PFEILGMBH.DE]
Sent: 6. juli 2001 13:20
To: XSL-Liste (E-Mail)
Subject: [xsl] 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