Re: Convert txt to xml

Discussion in 'XML' started by Martin Honnen, Feb 10, 2011.

  1. 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/
     
    Martin Honnen, Feb 10, 2011
    #1
    1. Advertising

  2. Martin Honnen

    Peter Flynn Guest

    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
     
    Peter Flynn, Feb 10, 2011
    #2
    1. Advertising

  3. Martin Honnen

    Peter Flynn Guest

    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
     
    Peter Flynn, Feb 10, 2011
    #3
  4. Martin Honnen

    John Redmond Guest

    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
     
    John Redmond, Feb 26, 2011
    #4
  5. 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
     
    Stanimir Stamenkov, Mar 5, 2011
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Davor
    Replies:
    4
    Views:
    475
    Davor
    Jun 14, 2006
  2. Steve
    Replies:
    3
    Views:
    27,028
    Steve
    Aug 25, 2006
  3. Sameen
    Replies:
    2
    Views:
    459
    Victor Bazarov
    Aug 29, 2005
  4. ZSP747
    Replies:
    1
    Views:
    334
  5. Jochen Brenzlinger
    Replies:
    7
    Views:
    5,687
    Roedy Green
    Sep 15, 2011
Loading...

Share This Page