Solved

Unable to Transform XML to desire output

Posted on 2008-06-23
3
516 Views
Last Modified: 2013-11-18
Hi,

I'm using an XSL to Transform an XML file to desire output. Everything working fine expect one thing!

Sample XML and XSL attached in code Snippet.

My Problem:
I unable to add a message which i would like to see at the last line in output file

Currently generating output file
-------------------------------------
ID=1
Name="Test"
Address="My Address"

ID=2
Name="Test1"
Address="My Address2"

My Desired output file.....
-------------------------------
ID=1
Name="Test"
Address="My Address"

ID=2
Name="Test1"
Address="My Address2"

Message: "Welcome come you all!"

==================
if you look at the above desired output file - I would like to see the "Message ......." tobe print at the last line of output file!

Here Sample XML File
 

<?xml version="1.0" encoding="UTF-8"?>

<Msg>

    <Data>

        <DataSet>

            <DataTable>

                <DataRow>

                    <ID>1</ID>

                    <Name>Test</Name>

                    <Address>My Address</Address>

                </DataRow>

                <DataRow>

                    <ID>2</ID>

                    <Name>Test1</Name>

                    <Address>My Address2</Address>

                </DataRow>

            </DataTable>

        </DataSet>

    </Data>

</Msg>
 

XSL file which i'm using to transfter above xml file to desire format
 

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">

    <xsl:output method="text" />

    <xsl:template match="DataRow">

  	ID='<xsl:value-of select="ID" />',

  	Name='<xsl:value-of select="Name" />',

  	Address='<xsl:value-of select="Address" />'
 

    <xsl:text></xsl:text></xsl:template>

</xsl:stylesheet>

Open in new window

0
Comment
Question by:Yogeshup
  • 2
3 Comments
 
LVL 82

Accepted Solution

by:
hielo earned 125 total points
ID: 21848024
try:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <xsl:output method="text" />
    <xsl:template match="//Msg/Date/DataSet/DataTable">
    	<xsl:apply-templates select="DataRow"/>
	<xsl:text>Welcome You all</xsl:text>
    </xsl:template>
    <xsl:template match="DataRow">
        ID='<xsl:value-of select="ID" />',
        Name='<xsl:value-of select="Name" />',
        Address='<xsl:value-of select="Address" />'
 
    <xsl:text></xsl:text></xsl:template>
</xsl:stylesheet>

Open in new window

0
 
LVL 1

Author Comment

by:Yogeshup
ID: 21848633
Hi,

When I apply the above xsl it generate output file somthing like below....

ID='1', Name='Test', Address='My Address' ID='2', Name='Test1', Address='My Address2'

No message in output file
0
 
LVL 82

Expert Comment

by:hielo
ID: 21849792
I misspelled Data. I incorrrectly typed Date instead. Update your code with this:
<xsl:template match="//Msg/Data/DataSet/DataTable">
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

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

929 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now