[xml-compile] namespace prefixes

Wes Young wes at ren-isac.net
Fri Oct 1 13:47:32 GMT 2010


On Sep 30, 2010, at 6:22 PM, Mark Overmeer wrote:

> Your documentation is still missing.

(that's why it's still ver .xx_1) :)

>
> Why is your interface like this:
>
>   my $iodef = XML::IODEF->new($h);
>   print $iodef->out(1)."\n"
>
> Now, the object cannot be reused.  I would say:
>
>   my $iodef = XML::IODEF->new;
>   print $iodef->out($h, 1),"\n";
>   print $iodef->out($z, 1),"\n";
>
> Instantiating this object is expensive.  In the second solution, you
> need only onw.
>
>    my $doc     = XML::LibXML::Document->new('1.0', 'UTF-8');
>    my $write   = $s->compile(WRITER => $type
>       , prefixes => [ iodef => 'urn:ietf:params:xml:ns:iodef-1.0' ]);
>    my $xml     = $write->($doc, $self->_hash());
>    return $xml->toString($pretty);

interesting thought, i'll have to play around with it. Honestly was  
trying to get everything to just "compile" first then deal with the  
semantics later. The ->in() (which i need to add) and ->out() was just  
how the original versions of this module were developed. So it was  
just carried over in that way to see how XML::Compile worked.

Good thoughts, i'll play around with it a bit. I did notice the cost  
of instantiation.

>
> You should add the $xml to the $doc. Only $doc->toString will produce
> correct character encodings.
>    $doc->setDocumentElement($xml);
>    return $doc->toString;
> But I see that this is a problem with the SYNOPSIS of ::Schema. Will
> be corrected in the next release.

neat. Thanks!

--
Wes
http://claimid.com/wesyoung

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
Url : http://lists.scsys.co.uk/pipermail/xml-compile/attachments/20101001/a06f3032/PGP.pgp


More information about the Xml-compile mailing list