xsl-list
[Top] [All Lists]

RE: number + document

2003-06-20 06:29:01
Hi

-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com 
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of 
abbouh
Sent: Wednesday, June 18, 2003 7:42 PM
To: XSL-List(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] number + document


i want to use nuber for each "ht" node in several document
so i use this xsl file:
<xsl:for-each select="//doccontent/chapmod">
<xsl:for-each 
select="document(concat(string(./attribute::docref),'.xml'))//ht">
<xsl:choose>
....
<xsl:number level="multiple"  count="chap1|chap2|chap3" 
format="A.1"/> .. <xsl:value-of select="."/> .. 
</xsl:for-each> </xsl:for-each>

and receive this output:

A title1
A title2
    A.1 paragraph1
      A.1.1 ss-paragraph1
      A.1.2 ss-paragraph2
      A.1.3 ss-paragraph3
    A.2 paragraph2
A title3


That's because xsl:number sees each chap diferently because they have
diferent parents.

but what i want to get is:

A title1
B title2
    B.1 paragraph1
      B.1.1 ss-paragraph1
      B.1.2 ss-paragraph2
      B.1.3 ss-paragraph3
    B.2 paragraph2
C title3

Try this:

<xsl:stylesheet exclude-result-prefixes="ms" version="1.0"
xmlns:ms="urn:schemas-microsoft-com:xslt"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
    <xsl:template match="doccontent">
        <!-- create ntf with all chapters -->
        <xsl:variable name="docs">
            <xsl:for-each select="chapmod">
                <xsl:for-each select="document(concat(@docref,'.xml'))">
                    <xsl:copy-of select="/doccontent/docbody/*"/>
                </xsl:for-each>
            </xsl:for-each>
        </xsl:variable>
        <!-- all chapters now have the same parent so the xsl:number should
work now -->
        <xsl:apply-templates select="ms:node-set($docs)" mode="chapters"/>
    </xsl:template>
    <xsl:template match="/" mode="chapters">
        <xsl:apply-templates mode="chapters"/>
    </xsl:template>
    <xsl:template match="chap1 | chap2 | chap3" mode="chapters">
        <xsl:number count="chap1 | chap2 | chap3" format="A.1"
level="multiple"/>
        <xsl:text>&#160;</xsl:text>
        <xsl:apply-templates select="ht"/>
        <xsl:text>&#10;</xsl:text>
        <xsl:apply-templates mode="chapters" select="*[not(self::ht)]"/>
    </xsl:template>
</xsl:stylesheet>

If you use another processor you'll have to change the ms namespace
accordingly. It's need is to use the node-set function, so you can use any
one you want that has a similar function (xalan, saxon, etc)

Hope this helps



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



<Prev in Thread] Current Thread [Next in Thread>