Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old February 22nd, 2006, 05:55 PM
CSUIDL PROGRAMMEr
Guest
 
Posts: n/a
Default 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

  #2  
Old February 22nd, 2006, 06:25 PM
Joseph Kesselman
Guest
 
Posts: n/a
Default Re: Example to transform xml to text file

CSUIDL PROGRAMMEr wrote:[color=blue]
> I am new to XSL and XSLT. I have xml file. I want to transform it in a
> text file.[/color]

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
  #3  
Old February 22nd, 2006, 09:25 PM
Jeff Calico
Guest
 
Posts: n/a
Default Re: Example to transform xml to text file

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

  #4  
Old February 22nd, 2006, 11:55 PM
CSUIDL PROGRAMMEr
Guest
 
Posts: n/a
Default Re: Example to transform xml to text file

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

  #5  
Old February 23rd, 2006, 04:15 AM
Joe Kesselman
Guest
 
Posts: n/a
Default Re: Example to transform xml to text file

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.
  #6  
Old February 23rd, 2006, 03:45 PM
Andrew Schorr
Guest
 
Posts: n/a
Default Re: Example to transform xml to text file

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
}
}'

  #7  
Old February 24th, 2006, 04:35 AM
Daniel Parker
Guest
 
Posts: n/a
Default Re: Example to transform xml to text file

"CSUIDL PROGRAMMEr" <syedamjad_a@yahoo.com> wrote in message
news:1140630282.299230.280870@f14g2000cwb.googlegr oups.com...[color=blue]
> 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
>[/color]
Have a look at the XML-to-flat examples in
http://servingxml.sourceforge.net/.

Regards,
Daniel Parker


 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles