Solved

Unable to Transform XML to desire output

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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

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‚Ķ
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.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

856 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