[jifty-devel] Idea for Template::Declare::XML

Andrew Sterling Hanenkamp sterling at hanenkamp.com
Thu Aug 9 23:07:11 EDT 2007

On 8/9/07, Andrew Sterling Hanenkamp <sterling at hanenkamp.com> wrote:
> On 8/9/07, Agent Zhang <agentzh at gmail.com> wrote:
> > __And__ it can optionally generate a DTD spec and/or an XML schema file
> > ;)
> Sure, why not?

Well, the obvious answer now that I'm thinking harder is that XML schema is
hard. That doesn't mean it can't be done and more readable than XML schemas
(and folks think Perl is obfuscated!), but looking at this problem from that
perspective takes a much different mindset than looking at this as a way for
generating a few subs.

After playing around with it further tonight, I came up with this:

tag 'serviceResponse' =>
    min_child_elements is 1,
    max_child_elements is 1,
    choose from qw/

tag 'authenticationFailure' =>
    max_child_elements is 0,
    type is 'string',
    attributes {
        attribute 'code' =>
            type is 'string',
            valid_values are qw/

I think that's pretty readable. And could result in a pretty straightforward
translation to to XML schema. This does tie the element declarations with
the types, which is typically separate in XML schemas, but one could hit it

I have two main problems with this pursuit though: (1) I hate XML and XML
schemas even more and (2) all I want is a simple way to declare XML tags
from the templating side. The more I think about it, this is super-overkill
for what I need. It would be nice if the declarations generated subs that
would croak if I did something bad like forget a required attribute or use
an attribute value that isn't valid, but whether or not I can generate a DTD
or schema from it isn't really relevant.

Therefore, I'm going to return to my less grand ideas from before, but try
to be conscious of someone wanting to build schemas off the work later and
allow for that. My primary interest will be in generating declarations that
will allow the templating code to check my templates to make sure they are
correct and either carp or croak on failures.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.bestpractical.com/pipermail/jifty-devel/attachments/20070809/92630216/attachment.htm

More information about the jifty-devel mailing list