[jifty-devel] Idea for Template::Declare::XML
Agent Zhang
agentzh at gmail.com
Thu Aug 9 05:53:44 EDT 2007
On 7/14/07, Andrew Sterling Hanenkamp <sterling at hanenkamp.com> wrote:
> Here's a sample of what I was thinking:
>
> use Template::Declare::XML;
> use Jifty::View::Declare schema {
> namespace cas => 'http://www.yale.edu/tp/cas';
> default_prefix is 'cas';
>
> tag serviceResponse =>
> is not_empty;
>
This is a wonderful way to generate XML schema file or even DTD file
using TD :) Anyone feels like hacking that in? ;)
>
> template 'serviceValidate' => sub {
> my $result = get 'result';
>
> xml_decl { version => 1.0, encoding => 'UTF-8' };
>
I've just committed a patch for the xml_decl sub but the API is now a
bit more general.
For instance,
xml_decl { 'xml', version => '1.0' };
xml_decl { 'xml-stylesheet', href => "chrome://global/skin/",
type => "text/css" };
will produce
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
>
> If there's a namespace prefix "cas" then it can infer this to be shorthand for:
>
> tag 'cas_serviceResponse' =>
> prefix 'cas',
> local_name 'serviceResponse',
> is not_empty;
>
To be honest, I'm not very happy with this way of specifying XML
namespaces since it's not flexible enough. I'm proposing using Perl
packages to emulate this kind of things. For example, html::div { ...
}, but we need to define the html package and import symbols into it
ourselves (sort of).
Cheers, agentz
More information about the jifty-devel
mailing list