Text parser

Discussion in 'Java' started by Martin Mozina, Sep 19, 2003.

  1. A part of my project is to create a .txt file for each person we are working
    it. I would like to make a common .txt template with some text that will not
    change, and at certain points in the text, I would insert tags with some
    query information (name for example) . Using this information and knowledge
    about current user, application should create a .txt file specific for this
    user.

    I could write a parser like that by myself. But if anyone knows for a text
    parser in java, that is capable to process text and user specific tags,
    would help me a lot.

    Martin
    Martin Mozina, Sep 19, 2003
    #1
    1. Advertising

  2. Martin Mozina wrote:
    > A part of my project is to create a .txt file for each person we are working
    > it. I would like to make a common .txt template with some text that will not
    > change, and at certain points in the text, I would insert tags with some
    > query information (name for example) . Using this information and knowledge
    > about current user, application should create a .txt file specific for this
    > user.
    >
    > I could write a parser like that by myself. But if anyone knows for a text
    > parser in java, that is capable to process text and user specific tags,
    > would help me a lot.


    Sounds exactly like what a JSP server does, though it can do a lot more and may be
    overkill.
    Michael Borgwardt, Sep 19, 2003
    #2
    1. Advertising

  3. Martin Mozina

    Stefan Poehn Guest

    "Martin Mozina" <> schrieb im Newsbeitrag
    news:bMAab.3271$...
    >
    > A part of my project is to create a .txt file for each person we are

    working
    > it. I would like to make a common .txt template with some text that will

    not
    > change, and at certain points in the text, I would insert tags with some
    > query information (name for example) . Using this information and

    knowledge
    > about current user, application should create a .txt file specific for

    this
    > user.
    >
    > I could write a parser like that by myself. But if anyone knows for a text
    > parser in java, that is capable to process text and user specific tags,
    > would help me a lot.


    Does it make sense to use XML in your application?
    You could use a DTD instead of your .txt templates and
    XML-files instead of your .txt-files.
    And you get a good parser by using Apache's SAX parser.

    HTH
    Stefan
    Stefan Poehn, Sep 19, 2003
    #3
  4. Martin Mozina

    D Goldman Guest

    Martin, why don't you try using java's StringTokenzer (in the util
    package). Also if you are trying to extract certain tags from a text
    file, then you should consider using an xml file with either SAX, DOM,
    or java's xml parser.

    Hope this helps,
    Daniel Goldman
    http://d-goldman.org




    "Martin Mozina" <> wrote in message news:<bMAab.3271$>...
    > A part of my project is to create a .txt file for each person we are working
    > it. I would like to make a common .txt template with some text that will not
    > change, and at certain points in the text, I would insert tags with some
    > query information (name for example) . Using this information and knowledge
    > about current user, application should create a .txt file specific for this
    > user.
    >
    > I could write a parser like that by myself. But if anyone knows for a text
    > parser in java, that is capable to process text and user specific tags,
    > would help me a lot.
    >
    > Martin
    D Goldman, Sep 19, 2003
    #4
  5. jflex is a lightweight easy to use parser - depending upon your application
    and the complexity of the data.

    "Martin Mozina" <> wrote in message
    news:bMAab.3271$...
    >
    > A part of my project is to create a .txt file for each person we are

    working
    > it. I would like to make a common .txt template with some text that will

    not
    > change, and at certain points in the text, I would insert tags with some
    > query information (name for example) . Using this information and

    knowledge
    > about current user, application should create a .txt file specific for

    this
    > user.
    >
    > I could write a parser like that by myself. But if anyone knows for a text
    > parser in java, that is capable to process text and user specific tags,
    > would help me a lot.
    >
    > Martin
    >
    >
    >
    J. Chris Tilton, Sep 19, 2003
    #5
  6. Martin Mozina

    Roedy Green Guest

    On Fri, 19 Sep 2003 12:21:09 +0200, "Martin Mozina"
    <> wrote or quoted :

    >I could write a parser like that by myself. But if anyone knows for a text
    >parser in java, that is capable to process text and user specific tags,
    >would help me a lot.


    The easy way is to use XML then use any XML parser. See
    http://mindprod.com/jgloss/xml.html The problem is the format is
    verbose.

    To roll your own parser, see http://mindprod.com/jgloss/parser.html

    If CSV will suffice, try http://mindprod.com/jgloss/csv.html

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Sep 19, 2003
    #6
  7. Martin Mozina

    Will Hartung Guest

    "Martin Mozina" <> wrote in message
    news:bMAab.3271$...
    >
    > A part of my project is to create a .txt file for each person we are

    working
    > it. I would like to make a common .txt template with some text that will

    not
    > change, and at certain points in the text, I would insert tags with some
    > query information (name for example) . Using this information and

    knowledge
    > about current user, application should create a .txt file specific for

    this
    > user.


    The XML option is certainly viable if it only needs to be Human readable vs
    Human formatted, and XML is a leveragable skill that can be used in all
    sorts of areas, so it worth learning for more than just this simple project.

    However, another generic utility is Jakarta Velocity project. While in some
    sense it may be a bit of overkill (as it's really a lightweight scripting
    language), Velocity is bone simple to use. You can have your own sample
    coded and running in 15 minutes. Vastly more easy than a generic XML
    framework.

    Regards,

    Will Hartung
    ()
    Will Hartung, Sep 19, 2003
    #7
  8. Martin Mozina

    Tim Tyler Guest

    Martin Mozina <> wrote:

    : I could write a parser like that by myself. But if anyone knows for a text
    : parser in java, that is capable to process text and user specific tags,
    : would help me a lot.

    FreeMarker does something like this:

    ``FreeMarker is a "template engine"; a generic tool to generate text
    output (anything from HTML or RTF to autogenerated source code) based
    on templates.''

    http://freemarker.sourceforge.net/
    --
    __________
    |im |yler http://timtyler.org/
    Tim Tyler, Sep 29, 2003
    #8
    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. Bernd Oninger
    Replies:
    0
    Views:
    754
    Bernd Oninger
    Jun 9, 2004
  2. ZOCOR

    XML Parser VS HTML Parser

    ZOCOR, Oct 3, 2004, in forum: Java
    Replies:
    11
    Views:
    809
    Paul King
    Oct 5, 2004
  3. Bernd Oninger
    Replies:
    0
    Views:
    810
    Bernd Oninger
    Jun 9, 2004
  4. Joel Hedlund
    Replies:
    2
    Views:
    502
    Joel Hedlund
    Nov 11, 2006
  5. mike b.
    Replies:
    3
    Views:
    159
    James Edward Gray II
    Jul 30, 2007
Loading...

Share This Page