473,811 Members | 3,737 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1710
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:0 5</time>
<sender>syed</sender>
<receiver>#IR C</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*********@ya hoo.com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.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
11459
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 billing_reports.xsl like this =====================================
2
1980
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 10:04:48" ModifiedBy="Smith, Geoff"><NameOfDog>Fido</NameOfDog><Weight>10</Weight></Dog><Dog TimeStamp="16.02.2004 10:05:24" ModifiedBy="Scott, Al"><Color>Black</Color><Weight>12</Weight></Dog></LogFile By the magic of some XSLT file I want the...
2
1188
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 the node into something readable to my users. My code works, however, I will be having multiple users calling my routines at the same time. So I don't want to create a "hard" copy of my html file and place on my server. Because every time a...
1
2689
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 <?xml version="1.0" encoding="windows-1255" ?><xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:utils="urn:galileo-com:msxsl-jscript-utilities" version="1.0"><xsl:template...
3
1836
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 = doc.CreateNavigator(); XslTransform xslTran = new XslTransform(); xslTran.Load("Transform.XSL"); xslTran.Transform(nav, null, Response.Output, null); This produces me a nice HTML page with enhanced formatting specified
3
302
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 transformed) doesn't. In the transform file I load the 2nd XML file which contains
4
2099
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 this? Thanks again WStoreyII
3
2757
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: <DOCUMENT> ...... ...... some lead elements ...... <SEGMENT_LIST>
1
1757
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: &lt;test&gt;this is a test&lt;/test&gt; I need to get <test>this is a test</testrather than the escaped data. Any input would be appreciated.
0
10651
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10393
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9208
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7671
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5556
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5697
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4342
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3871
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3020
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.