Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Text parser

Reply
Thread Tools

Text parser

 
 
Martin Mozina
Guest
Posts: n/a
 
      09-19-2003

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



 
Reply With Quote
 
 
 
 
Michael Borgwardt
Guest
Posts: n/a
 
      09-19-2003
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.

 
Reply With Quote
 
 
 
 
Stefan Poehn
Guest
Posts: n/a
 
      09-19-2003
"Martin Mozina" <(E-Mail Removed)> schrieb im Newsbeitrag
news:bMAab.3271$(E-Mail Removed)...
>
> 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



 
Reply With Quote
 
D Goldman
Guest
Posts: n/a
 
      09-19-2003
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" <(E-Mail Removed)> wrote in message news:<bMAab.3271$(E-Mail Removed)>...
> 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

 
Reply With Quote
 
J. Chris Tilton
Guest
Posts: n/a
 
      09-19-2003
jflex is a lightweight easy to use parser - depending upon your application
and the complexity of the data.

"Martin Mozina" <(E-Mail Removed)> wrote in message
news:bMAab.3271$(E-Mail Removed)...
>
> 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
>
>
>



 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      09-19-2003
On Fri, 19 Sep 2003 12:21:09 +0200, "Martin Mozina"
<(E-Mail Removed)> 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.
 
Reply With Quote
 
Will Hartung
Guest
Posts: n/a
 
      09-19-2003
"Martin Mozina" <(E-Mail Removed)> wrote in message
news:bMAab.3271$(E-Mail Removed)...
>
> 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
((E-Mail Removed))


 
Reply With Quote
 
Tim Tyler
Guest
Posts: n/a
 
      09-29-2003
Martin Mozina <(E-Mail Removed)> 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/ http://www.velocityreviews.com/forums/(E-Mail Removed)
 
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
Text parser (text into sentences) that works with UTF-8 and multiple languages? mike b. Ruby 3 07-30-2007 12:52 PM
import parser does not import parser.py in same dir on win Joel Hedlund Python 2 11-11-2006 03:46 PM
XML Parser VS HTML Parser ZOCOR Java 11 10-05-2004 01:58 PM
XMLparser: Difference between parser.setErrorHandler() vs. parser.setContentHandler() Bernd Oninger Java 0 06-09-2004 01:26 AM
XMLparser: Difference between parser.setErrorHandler() vs. parser.setContentHandler() Bernd Oninger XML 0 06-09-2004 01:26 AM



Advertisments