<br><br><div><span class="gmail_quote">On 8/9/07, <b class="gmail_sendername">Andrew Sterling Hanenkamp</b> &lt;<a href="mailto:sterling@hanenkamp.com">sterling@hanenkamp.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<span class="q">On 8/9/07, <b class="gmail_sendername">Agent Zhang</b> &lt;<a href="mailto:agentzh@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">agentzh@gmail.com</a>&gt; wrote:</span><span class="gmail_quote">

</span><br><div><span class="q"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">__And__ it can optionally generate a DTD spec and/or an XML schema file ;)
</blockquote></span><div><br>Sure, why not?</div></div></blockquote><div><br>Well, the obvious answer now that I&#39;m thinking harder is that XML schema is hard. That doesn&#39;t mean it can&#39;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.
<br><br>After playing around with it further tonight, I came up with this:<br><br>tag &#39;serviceResponse&#39; =&gt;<br>&nbsp;&nbsp;&nbsp; min_child_elements is 1,<br>&nbsp;&nbsp;&nbsp; max_child_elements is 1,<br>&nbsp;&nbsp;&nbsp; choose from qw/<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; authenticationSuccess
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; authenticationFailure<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; proxySuccess<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; proxyFailure<br>&nbsp;&nbsp;&nbsp; /;<br><br>tag &#39;authenticationFailure&#39; =&gt;<br>&nbsp;&nbsp;&nbsp; max_child_elements is 0,<br>&nbsp;&nbsp;&nbsp; type is &#39;string&#39;, <br>&nbsp;&nbsp;&nbsp; attributes {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; attribute &#39;code&#39; =&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; type is &#39;string&#39;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; valid_values are qw/<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; INVALID_REQUEST INVALID_TICKET INVALID_SERVICE INTERNAL_ERROR<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /;<br>
&nbsp;&nbsp;&nbsp; };<br><br>I think that&#39;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 harder.
<br><br>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&#39;t valid, but whether or not I can generate a DTD or schema from it isn&#39;t really relevant.
<br><br>Therefore, I&#39;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.
<br><br>Cheers,<br>Andrew<br></div></div><br>