[xml-compile] namespace prefixes
Mark Overmeer
mark at overmeer.net
Thu Sep 30 22:22:03 GMT 2010
* Wes Young (wes at ren-isac.net) [100930 21:45]:
> http://code.google.com/p/perl-xml-iodef/source/browse/trunk/lib/XML/IODEF.pm
> http://code.google.com/p/perl-xml-iodef/source/browse/trunk/example.pl
Your documentation is still missing.
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);
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.
It would be nice to have a bit more abstraction around the
construction of the complex nested HASH... but that's usually
a lot of work. Gladly, this schema is simple.
--
Good work.
MarkOv
------------------------------------------------------------------------
Mark Overmeer MSc MARKOV Solutions
Mark at Overmeer.net solutions at overmeer.net
http://Mark.Overmeer.net http://solutions.overmeer.net
More information about the Xml-compile
mailing list