473,387 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Example to transform xml to text file

Folks
I am new to XSL and XSLT. I have xml file. I want to transform it in a
text file.
IS there any way or example that i can learn and see.
thanks

Feb 22 '06 #1
6 1690
CSUIDL PROGRAMMEr wrote:
I am new to XSL and XSLT. I have xml file. I want to transform it in a
text file.


First you need to decide what information you want to copy out of the
XML file, in what order.

Then write an XSLT stylesheet which yields that data, using the
<xsl:output method="text"/> directive to say you want to produce bare
text rather than XML or HTML markup.

Check the web for XSLT tutorials; some of 'em must illustrate this...
--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Feb 22 '06 #2
This previous discussion between Joe and myself may be useful to you;
if not precisely the blank lines problem...

"unwanted blank lines in output when using xalan" Feb 7

http://groups.google.com/group/comp....5d57d40d7ad3e3

--Jeff

Feb 22 '06 #3
ok
here is a sample of my xml file

msg>
<date>2006-02-19</date>
<time>10:52:05</time>
<sender>syed</sender>
<receiver>#IRC</receiver>
<data>kjkk</data>
</msg>

I want output to be in this form in text file

(Date:time) sender data receiver

example

(2006-02-19:10:52:05) syed kjkk #IRC

thank

Feb 22 '06 #4
XSLT is a programming language. There are multiple ways the simple
transform you've described could be written. Which is best depends on
what you're doing.

In any case, this really is something you ought to be able to write for
yourself after reading an XSLT tutorial or two; it's not much more than
"hello world". I'm afraid I'm going to refer you to those resources;
you'll learn more from those than from my handing you the answer.
Feb 23 '06 #5
Using xgawk from http://sourceforge.net/projects/xmlgawk, you can solve
the problem
with this script:

xgawk -lxml '
{
switch (XMLEVENT) {
case "STARTELEM":
if (XMLNAME == "msg")
delete data
name = XMLNAME
break
case "CHARDATA":
if ($1 != "")
data[name] = $0
break
case "ENDELEM":
if (XMLNAME == "msg")
printf "(%s:%s) %s %s
%s\n",data["date"],data["time"],data["sender"],data["data"],data["receiver"]
break
}
}'

Feb 23 '06 #6
"CSUIDL PROGRAMMEr" <sy*********@yahoo.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Folks
I am new to XSL and XSLT. I have xml file. I want to transform it in a
text file.
IS there any way or example that i can learn and see.
thanks

Have a look at the XML-to-flat examples in
http://servingxml.sourceforge.net/.

Regards,
Daniel Parker
Feb 24 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: robert walker | last post by:
hi all, can someone help me with this I have xml file on my web server (iplanet) and want to to load them from a client (internet explorer) and see the transformed xml in html my xslt is...
2
by: Daniel Walzenbach | last post by:
Hi I need to know how to transform a XML file by using a XSLT file. Consider the following XML file <?xml version="1.0" encoding="UTF-8" standalone="yes"?><LogFile><Dog TimeStamp="16.02.2004...
2
by: K riley | last post by:
Hi. I am using the transform method to create an HTML file using an existing XML Document and an XLST. I need to use XPath to extract a node from my XML Document and my XLST document will format...
1
by: Danny Lesnik | last post by:
Hi i have my XML file c:\prd.xm <?xml-stylesheet type="text/xsl" href="prd.xsl"?><products><product><a>2</a><b>3</b></product><product><a>4</a><b>2</b></product></products This is my XSL file...
3
by: vitaly.tomilov | last post by:
I'm using an ASP.NET form to display data from my database table, and I'm doing it in the following way: XmlDataDocument doc = new XmlDataDocument(mydataSet); XPathNavigator nav =...
3
by: Peter Row | last post by:
Hi, I have 2 XML files and 1 XSLT file. The second XML file has the following declarative 1st line: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> ....the 1st one (the one to be...
4
by: WStoreyII | last post by:
I wish to know how to set it up so that when an xml webservice is called that instead of displaying the xml in the browser it will render it with a xslt file the problem is i dont know how to do...
3
by: R. P. | last post by:
Subject: XSLT to transform a flat XML file into a structured text file I have an XML file that lists the PDF file segment names and titles of a larger document and looks something like this: ...
1
by: the_dog_gabby | last post by:
Hello, I have a stylesheet that contains C# functions to generate XML. When I apply the stylesheet to my document, everything works perfectly except the data I get back is escaped like so: ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.