From: "Christian Sell" <[EMAIL PROTECTED]>
> Hello,
>
> I am trying to port an ANT-based tag library over to Jelly and have the
> following questions:

Firstly, if you have some existing Ant tasks, they will just work inside the
Ant library for Jelly. (You may need to perform a <taskdef> first).


> - is there a way to create tags such that nested elements will be
> created via reflction like in ANT, or do I have to implement & register
> tag classes even for all tags that occur only on nested levels in my
script?

Sure its possible. This is what the Ant library does right now.

Also there's a bean library which uses a simplified (but similar) bean-like
way to create beans and connect them together For example here's the
JellyUnit test case showing it in action..

http://cvs.apache.org/viewcvs/jakarta-commons-sandbox/jelly/jelly-tags/bean/
src/test/org/apache/commons/jelly/tags/bean/suite.jelly?rev=HEAD

To create this library, only the root bean (Customer) was registered, the
orders and product beans are set on a customer via introspection and a
couple of other methods (createFoo() and either addFoo() or setFoo());

http://cvs.apache.org/viewcvs.cgi/jakarta-commons-sandbox/jelly/jelly-tags/b
ean/src/test/org/apache/commons/jelly/tags/bean/MyTagLibrary.java?rev=HEAD



> - is there some way to automatically enforce a specific syntax (like a
> DTD),

Jelly is just XML so use any kind of XML validation technology you wish to
validate the XML (DTD, XML Schema, RelaxNG, Schematron etc)


> or do my tags have to perform syntax validation of their own
> (presumably in method doTag())?

Jelly usually does some validation for you - i.e. if you add an attribute to
a Tag that doesn't exist or is the wrong type (e.g. can't convert to a
number) it'll generate an error. Right now if Jelly doesn't find a Tag
implementation to use for an XML element, it just leaves it as some static
XML. I'm sure that could be disabled so that if an element is mispelled an
error could be generated.

When it comes to more complex validation, like that <j:case> should be
inside <j.switch> then normally thats quite easy to do a quick check inside
the Tag implementation. In these kinds of situations, where a child tag must
be inside some parent tag, the code will already be calling
findAncestorWithClass() and so its just a matter of adding an if() into the
code.

James
-------
http://radio.weblogs.com/0112098/

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to