How to define my own tags ?

Hi !

As I posted a message 2 secs ago and it didn't appear (?) in the message list, I retype it ! (please excuse me if it appears twice)

So ... my problem is : I need to define my own tags, such as the "?php" tag, so that it can be processed by my own servlet / application.

For instance, something like (excuse me tag delimiters don't seem to be accepted in posts, so I sadly replaced them with quotes) :

"ownTag"

Write "JAVA is good for health" in bold and italic.

"/ownTag"

would be redirected to my *application* (from now, the processing tool I need to design will be referred as "application"), that would output the following HTML code :

"B" "I" JAVA is good for health "/I" "B" .

By now I have quite few ideas on how to build this application...

I first thought of an Apache Module, but, besides the fact that Apache Modules *have* to be written in C (not definitively sure of that...) and that I don't know C, I think that JAVA would be much more universal (and efficient ?), using servlets or JavaBeans ...

I know my problem is not that easy to solve, though I think people more experienced than me in servlets, JavaBeans, and/or Apache could tell me if building this application is realistic or if I must stop dreaming !!!

Any hint, method, theory, even code (!) would be greatly appreciated, and rewarded (it's Sun's cyber-money, anyway !!).

Thanks in advance

stephmor (stephanemor@yahoo.fr)

NB 1 : The Natural Language (french !) processor is 99% efficient in PHP, 49% in JAVA (I translated it in JAVA for greater performance), so the last thing I need really is this definition of tags, so that functions written in Natural Language can be directly processed by the application (on the server side), without any additional code / programming language.

NB 2 : As the multi-language ability of the projected application is my Number One priority, the whole application is structured so that every language can easily be used and processed (after having translated the function names in the target language, of course). So, if you're interested in the project and you're not french (I am quite sure some people on Earth are not french !!), let's keep in touch !

NB 3 : The whole thing will be Open Source.

NB 4 : I know I talk too much ! ;)

[2382 byte] By [stephmor] at [2007-9-26 1:28:36]
# 1

Hi Stephmor,

I have been developing my custom tags too, but unfortunately I don't have the source code anymore.

Perhaps I can send you in the right direction:

- Study the javax.servlet.jsp.tagext package

- check out www.jsptags.com

Hope this helps,

Surf

NLSurfMan at 2007-6-29 1:14:37 > top of Java-index,Archived Forums,Java Programming...
# 2
The off-the-shelf solution is to write an XSLT file that converts your custom tags to HTML, and configure Apache with Cocoon to convert them before it serves the file. Way to go!
chrishmorris at 2007-6-29 1:14:37 > top of Java-index,Archived Forums,Java Programming...
# 3

Thanks for answering, guys !

After having considered both answers, learned a bit more about servlets and Cocoon, it seems to me that javax.servlet.jsp.tagext can be very useful to me, as it has the server-side abilities I need.

Though, as my functions' definitions are structured with XML, Cocoon seems to be the most appropriate to parse and deliver the whole stuff, even if I find it hard to understand how it works with Apache. Moreover, if the XML structure is very user-friendly, XSLT looks quite close to chinese to me !!!

So, do you think both technologies (servlets & cocoon) can work together so that I can have Cocoon sending instructions to a servlet, or something like that (it may be the other way around, I didn't clearly identify how those technologies interact with a server...) ?

The way I think this could work altogether looks like something like that :

HTML CUSTOM TAG

|

|-- *SERVLET / COCOON ?* -- XML SOURCE (function names and stuff)

..........|

..........|

..........|-- APACHE --> HTML OUTPUT

Do you think this schema is correct ?

The fact is that I'm not quite sure how the connexion *SERVLET / COCOON* -- APACHE can work ...

If you see something like a big bug in this schema, please let me know !

Anyway thanks again *NLSurfMan* and *chrishmorris* for having taken the time to answer me !

stephmor

stephmor at 2007-6-29 1:14:37 > top of Java-index,Archived Forums,Java Programming...