Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Re: Convert txt to xml

Reply
Thread Tools

Re: Convert txt to xml

 
 
Martin Honnen
Guest
Posts: n/a
 
      02-10-2011
Crosspost and followup-to comp.text.xml

hssig wrote:
> Hi,
>
> can someone recommend an editor which is capable of converting a
> simple text file into a xml file ?


I am not familiar with editors doing that but XSLT 2.0 can use the
functions unparsed-text to read in text files and the function tokenize
and the instruction analyze-string to extract data and can then output XML.
Of course you would need to post a small but representative sample of
the plain text you have and the corresponding XML you want to create.



--

Martin Honnen
http://msmvps.com/blogs/martin_honnen/
 
Reply With Quote
 
 
 
 
Peter Flynn
Guest
Posts: n/a
 
      02-10-2011
On 10/02/11 11:22, Martin Honnen wrote:
> Crosspost and followup-to comp.text.xml
>
> hssig wrote:
>> Hi,
>>
>> can someone recommend an editor which is capable of converting a
>> simple text file into a xml file ?

>
> I am not familiar with editors doing that but XSLT 2.0 can use the
> functions unparsed-text to read in text files and the function tokenize
> and the instruction analyze-string to extract data and can then output XML.
> Of course you would need to post a small but representative sample of
> the plain text you have and the corresponding XML you want to create.


Emacs with psgml-mode and xxml-mode (or nxml-mode) should be able to
help. You can use REs to detect patterns and apply markup to the
paragraph level first (while remaining non-well-formed) and then add in
sufficient containment to suit your needs.

But I would echo Martin's advice: we would need to see what you mean by
"a simple text file"

///Peter
 
Reply With Quote
 
 
 
 
Peter Flynn
Guest
Posts: n/a
 
      02-10-2011
On 10/02/11 20:12, Peter Flynn wrote:
> On 10/02/11 11:22, Martin Honnen wrote:
>> Crosspost and followup-to comp.text.xml
>>
>> hssig wrote:
>>> Hi,
>>>
>>> can someone recommend an editor which is capable of converting a
>>> simple text file into a xml file ?

>>
>> I am not familiar with editors doing that but XSLT 2.0 can use the
>> functions unparsed-text to read in text files and the function tokenize
>> and the instruction analyze-string to extract data and can then output
>> XML.
>> Of course you would need to post a small but representative sample of
>> the plain text you have and the corresponding XML you want to create.

>
> Emacs with psgml-mode and xxml-mode (or nxml-mode) should be able to
> help. You can use REs to detect patterns and apply markup to the
> paragraph level first (while remaining non-well-formed) and then add in
> sufficient containment to suit your needs.
>
> But I would echo Martin's advice: we would need to see what you mean by
> "a simple text file"


I should have added that the standard text utilities are also usable for
this. awk and perl in particular would be good for matching patterns and
surrounding text with tags according to rules you write.

///Peter
 
Reply With Quote
 
John Redmond
Guest
Posts: n/a
 
      02-26-2011
On 10/02/11 22:22, Martin Honnen wrote:
> Crosspost and followup-to comp.text.xml
>
> hssig wrote:
>> Hi,
>>
>> can someone recommend an editor which is capable of converting a
>> simple text file into a xml file ?

>
> I am not familiar with editors doing that but XSLT 2.0 can use the
> functions unparsed-text to read in text files and the function tokenize
> and the instruction analyze-string to extract data and can then output XML.
> Of course you would need to post a small but representative sample of
> the plain text you have and the corresponding XML you want to create.
>
>
>

You might be interested in my site (www.limpidsoft.com). It is primarily
about using text source from www.gutenberg.org to generate XML, XHTML
and LaTeX/PDF.

Look at the lexxia-overview and about-lexxia pages, which have the
detail. Put simply, you will need to download the scripts zip file and
use the t2x script to process your text:

cat <yourtextfile> | t2x > <resultname).xml

You need to know that the scripts are best in a Linux environment,
though, because they are Tcl scripts, they should work just about
anywhere--provided that Tcl has been installed.

I hope that this helps,
John Redmond


 
Reply With Quote
 
Stanimir Stamenkov
Guest
Posts: n/a
 
      03-05-2011
Thu, 10 Feb 2011 12:22:19 +0100, /Martin Honnen/:
> hssig wrote:
>
>> can someone recommend an editor which is capable of converting a
>> simple text file into a xml file ?

>
> I am not familiar with editors doing that but XSLT 2.0 can use the
> functions unparsed-text to read in text files and the function
> tokenize and the instruction analyze-string to extract data and can
> then output XML.
> Of course you would need to post a small but representative sample
> of the plain text you have and the corresponding XML you want to
> create.


I haven't used it myself but I'm aware there's (Java-based)
ServingXML [1] framework for flat/XML data transformations.

[1] http://servingxml.sourceforge.net/

--
Stanimir
 
Reply With Quote
 
 
 
Reply

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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
counting how often the same word appears in a txt file...But my codeonly prints the last line entry in the txt file dgcosgrave@gmail.com Python 8 12-19-2012 06:29 PM
Diff. between FileWriter("f.txt") and OutputStreamWriter(new FileOutputStream("f.txt")) ? Jochen Brenzlinger Java 7 09-15-2011 01:23 AM
How to convert a .txt file extension to a .xls file extension? Steve ASP .Net 3 08-25-2006 05:43 PM
convert .pdf files to .txt files Davor Python 4 06-14-2006 12:23 PM
Opening a txt file to view ( i.e. readme.txt) Sameen C++ 2 08-29-2005 03:14 PM



Advertisments