Solved

Unable to Transform XML to desire output

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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
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…

730 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