Solved

Unable to Transform XML to desire output

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
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. 
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

785 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