Solved

XSLT help

Posted on 2011-03-09
1
153 Views
Last Modified: 2012-05-11
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
Comment
Question by:Techsavy
1 Comment
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 35093202

<?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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question