Will Glass-Husain wrote:
I've been having the same issue using Velocity to autogenerate XML.
There's
a benefit to using an XML editor on the template (I'm using the XML buddy
plugin) since it does autocompletions, etc. But most editors choke on the
extra-XML syntax (such as #if's).
My favorite editor is oXygenXML (http://oxygenxml.com)
- one license for mac, linux, windows
- can be used as an eclipse plugin or standalone (with more features)
There's really three issues I've found.
One is formatting text within a tag. Most editors work fine with this.
<Data>A $reference goes here#if($condition)$another#end</Data>
Second is showing or hiding complete tags. Some editors work with this
(XMLBuddy does acceptably), others choke.
#if($condition) <Data>dkfjadskfjadks</Data>#end
This would probably depend on whether validation (schema or dtd) is
turned on. If the schema does not allow cdata at that position then it
probably throughs an error.
And the third is hiding/showing attributes
<Data #if($condition)$att="test"/>
Most editors fail on this. Sometimes they'll do ok with this instead.
#set($att = "att = 'abc'")
<Data $att />
This is probably the biggest problem. The above is simply not XML. I
have gone with the solution you (Will) provided a few months ago. That
is if I need to do something like
<input type="checkbox" #if($isChecked)selected="selected"#end/>
I now put it into a macro, passing the instance specific info.
Anyone have other experiences?
It sounds like my experiences are different in that I need well-formed
source templates that I use in an XSL transformation (I don't
necessarily care if the output is well-formed). This transformation
produces a full, say, (X)HTML page that now possibly contains some
velocity code. This file is pregenerated (this is what my CMS does),
i.e. not done at runtime - just the velocity code is processed at
runtime. So, in a way, I have 'pre-cached' most of the page.
I really like like XSL. I like that it is a standard and that there are
*really* solid implementations out there (my preference is Saxon, but I
keep checking on Xalan). Then of course there are browser based
transformations that are more likely than not available today.
I don't want to use XSL at runtime because I don't want to build a DOM
for each page request. A DOM (most likely an optimized internal one in
the case of Saxon and Xalan, but still...) must be built for every XSL
transformation (though the template can be cached). I do use XSL if I am
getting a SOAP/WebService request hat contains some data dump rather
than converting.
I have looked at quite a few templating engines. From what I understand
there are now two that can work as I need them - Velocity which I have
been very happy with and now Freemarker's current trunk. I feel safer
with Velocity at this point. Yes, there is a well-formed JSP XML syntax,
but neither Tomcat nor Resin handle the syntax as well as the older one
(there was always some little problem).
And I really like that Velocity can only do 'a little.' It nicely
seperates out concerns so that less technical folk can create/edit
simple templates. I love being able to point to a relatively short
one-page user manual.
best,
-Rob
WILL
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]