Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Counter in XML

Status
Not open for further replies.

stdf23173

Technical User
Jan 4, 2005
7
NL
Hello All,

I am using XMLMind to edit my document.

This document has several chapters/subchapters and tables.
The first cell in this table needs to have a number, reflecting the chapter and a number following it.

I tried this, but all i get is "1.1".
So each time i insert a counter in a cell, it is reset again !

Mind you, XMLMind does not have all the counter features as described on/in the net / books.

grtz

Simon

 
Could probably number it with XSL fairly easily. Post your XML.
 
if i could i would :D

First of all, the document is very large (1000 pages).
Second, the content is IP.

sorry


grtz

Simon
 
OK. Post or describe the XML structure. Or develop the XSL yourself if you know how.
 
Thank you for your reply !

My document looks like :

<document>
<sect1>
<title></title>
<para></para>
<sect2> <title></title>
<para></para>
</sect2>
</sect1>
<sect1>
<title></title>
<para></para>
<sect2> <title></title>
<para></para>
<table>
<tgroup>
<thead>
<row>
<entry>AA<entry>
<entry>BB<entry>
</row>
</thead>
<tbody>
<row>
<feature>F<feature>
<entry>CC<entry>
</row>
</tbody>
</tgroup>
</table>
</sect2>
</sect1>
</document>

All cells with <feature> must be numbered according to chapter number (single digit) and a number reflecting the xth digit.

I use css to style it !
But i already figured out that xsl would be more convenient.
Since i do not have time to (re-)write a style sheet i only can extend or add things with css or xsl.

grtz

Simon







 
CSS is the right thing to style it with. The name of XSL is a bit misleading, you don't really style XML with it, you change its structure.

So, the chapter number is denoted by what 'sect1' element the <feature> is in. What is "a number reflecting the xth digit"?
 

I have e.g. 4 chapters. Each chapter has several tables.
Each first cell needs to have this chapter (sect1) number plus the number which reflects what table number it is !

for example; chapter 1 has 4 tables, chapter 2 has 3, chapter 3 has 12 and chapter 4 has just 1.
That means that i will get 1.1, 1.2, 1.3, 1.4, 2.1, 2.2 etc......

grtz

Simon

 
Try this:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="feature">
        <feature count="{concat(1+count(../../../../../../preceding-sibling::*), '.', count(../../../../preceding-sibling::*)-1)}">
            <xsl:value-of select="."/>
        </feature>
    </xsl:template>
</xsl:stylesheet>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top