Text parser

M

Martin Mozina

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
 
M

Michael Borgwardt

Martin said:
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.
 
S

Stefan Poehn

Martin Mozina said:
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
 
D

D Goldman

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
 
J

J. Chris Tilton

jflex is a lightweight easy to use parser - depending upon your application
and the complexity of the data.
 
W

Will Hartung

Martin Mozina said:
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
([email protected])
 
T

Tim Tyler

: 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/
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top