Okay, so after discussions in the other thread about the Template::Declare::Tags stuff, the revision here is that the Template::Declare::XML would be used to declare a TagSet package that could then be imported into any template package.
<br><br>For example, in CASPlus, I might add packages like this:<br><br>package CASPlus::TagSet::CAS;<br><br>use Template::Declare::XML;<br>use Template::Declare::TagSet schema {<br> tag serviceResponse =><br> is not_empty;
<br><br> # more tag definitions<br>};<br><br>package CASPlus::View;<br>use Jifty::View::Declare -base;<br><br># This is a customized subclass of Template::Declare::Tags that nows to look for ->app_class('TagSet', 'CAS')
<br>use Jifty::Tags 'CAS' => { namespace => 'cas' };<br><br>template 'serviceValidate' => sub {<br> xml_decl { 'xml', version => '1.0' };<br><br> cas::serviceResponse {
<br> # more stuff<br> };<br>};<br><br>I like that a lot. It does much better at separating the concerns than my first suggestion.<br><br>Cheers,<br>Andrew<br><br><div><span class="gmail_quote">On 8/9/07, <b class="gmail_sendername">
Andrew Sterling Hanenkamp</b> <<a href="mailto:sterling@hanenkamp.com">sterling@hanenkamp.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
agentz,<br><br>The TagSet stuff in TD is cool, btw.<br><br><div><span class="q"><span class="gmail_quote">On 8/9/07, <b class="gmail_sendername">Agent Zhang</b> <<a href="mailto:agentzh@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
agentzh@gmail.com</a>> wrote:</span>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">On 7/14/07, Andrew Sterling Hanenkamp <<a href="mailto:sterling@hanenkamp.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
sterling@hanenkamp.com
</a>> wrote:<br>> Here's a sample of what I was thinking:<br>><br>> use Template::Declare::XML;<br>> use Jifty::View::Declare schema {<br>> namespace cas => '<a href="http://www.yale.edu/tp/cas" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://www.yale.edu/tp/cas</a>';<br>> default_prefix is 'cas';<br>><br>> tag serviceResponse =><br>> is not_empty;<br>><br><br>This is a wonderful way to generate XML schema file or even DTD file
<br>using TD :) Anyone feels like hacking that in? ;)</blockquote></span><div><br>I want to, but I don't know when I would be able to commit. Maybe sometime over the next month, but probably not in the next week or two.
<br></div><span class="q">
<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">><br>> template 'serviceValidate' => sub {<br>> my $result = get 'result';
<br>><br>> xml_decl { version => 1.0, encoding => 'UTF-8' };<br>><br><br>I've just committed a patch for the xml_decl sub but the API is now a<br>bit more general.<br><br>For instance,<br><br>
xml_decl { 'xml', version => '1.0' };<br> xml_decl { 'xml-stylesheet', href => "chrome://global/skin/",<br>type => "text/css" };<br><br>will produce<br><br> <?xml version="
1.0"?><br> <?xml-stylesheet href="chrome://global/skin/" type="text/css"?></blockquote></span><div><br>Good idea. <br></div><span class="q"><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
><br>> If there's a namespace prefix "cas" then it can infer this to be shorthand for:<br>><br>> tag 'cas_serviceResponse' =><br>> prefix 'cas',<br>> local_name 'serviceResponse',
<br>> is not_empty;<br>><br><br>To be honest, I'm not very happy with this way of specifying XML<br>namespaces since it's not flexible enough. I'm proposing using Perl<br>packages to emulate this kind of things. For example, html::div { ...
<br>}, but we need to define the html package and import symbols into it<br>ourselves (sort of).</blockquote></span><div><br>Yeah, I wasn't precisely pleased with this myself, but it would have been flexible enough for what I was considering at the time. :-P
<br><br>The package idea is interesting, I'd be interested to see an example of how you would declare it and use it.<br><br>Cheers,<br>Andrew<br></div></div><br>
</blockquote></div><br>