[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 160
  • Last Modified:

XSLT help

Hi,

I have the attached XML and I would like to number the child Elements using XSLT.

For eg from the attached XML I need:

1.child
1.1child
1.1.1child


2 child

2.1 child

3 child

3.1 child
InputXML.txt
0
Techsavy
Asked:
Techsavy
1 Solution
 
Geert BormansCommented:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0">
    <xsl:output indent="yes"/>
<xsl:template match="root">
    <html>
        <body>
            <xsl:apply-templates select="child"/>
        </body>
    </html>
</xsl:template>
    <xsl:template match="child">
        <p>
            <xsl:number format="1.1.1.1.1." count="child" level="multiple"/>
            <xsl:text> </xsl:text>
            <xsl:value-of select="name()"/>
        </p>
        <xsl:apply-templates select="child"/>
    </xsl:template>
</xsl:stylesheet>

Open in new window

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now