Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

XSLT help

Posted on 2011-03-09
1
154 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

792 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