|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: numbering empty entities
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








