Solved

Unable to Transform XML to desire output

Posted on 2008-06-23
3
513 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

747 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