Solved

xml to xml through xslt

Posted on 2014-12-14
3
196 Views
Last Modified: 2014-12-15
Hi,

i am trying to use an xslt to convert .xml to .xml , but i am not sure how to


How do i change the following xml
<FS>
<Captions>
                                                <Caption id="1">Income</Caption>
                                                <Caption id="2">-Deductions</Caption>
                                                <Caption id="3">-Expenses</Caption>
                                                <Caption id="4">=Net income</Caption>
                                                <Caption id="5">Income limit to qualify</Caption>
  </Captions>
</FS>

to the below xml using an xslt

<FS>
<Captions>
                                                <Caption1>Income</Caption1>
                                                <Caption2>-Deductions</Caption2>
                                                <Caption3>-Expenses</Caption3>
                                                <Caption4>=Net income<Caption4>
                                                <Caption5>Income limit to qualify</Caption5>
   </Captions>
</FS>


Thanks in Advance
reddtsi
0
Comment
Question by:reddytsi
[X]
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
  • 2
3 Comments
 
LVL 36

Accepted Solution

by:
mccarl earned 500 total points
ID: 40499405
This is a fairly general solution, that will transform "Caption" elements in any context. You can, of course, tweak it to be more specific if required.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" indent="yes" />

    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()" />
        </xsl:copy>
    </xsl:template>

    <xsl:template match="Caption">
        <xsl:element name="{concat('Caption', @id)}">
            <xsl:apply-templates select="node()" />
        </xsl:element>
    </xsl:template>
</xsl:stylesheet>

Open in new window

0
 

Author Comment

by:reddytsi
ID: 40499450
Thank you mccarl
0
 
LVL 36

Expert Comment

by:mccarl
ID: 40499451
You're welcome!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
In this post we will learn different types of Android Layout and some basics of an Android App.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

707 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