* David Schmidt via RT (bug-XML-LibXML-Simple@rt.cpan.org) [160504 08:18]:
Show quoted text> Queue: XML-LibXML-Simple
> Ticket <URL:
https://rt.cpan.org/Ticket/Display.html?id=114021 >
>
> > > As you can see in the attached example the first item is "overriden"
> > > without any warning. I am not saying that XML::LibXML::Simple is
> > > wrong here, but I dont know enough about XML to figure out where
> > > the error lies.
(I'm just back after holidays)
Show quoted text> > $ perl -w test.pl
> > <item> element has non-unique value in 'id' key attribute: id-123 at
> > /usr/perl5.22.1sp/lib/site_perl/5.22.1/XML/LibXML/Simple.pm line 463.
> > $VAR1 = {
> > 'result' => {
> > 'item' => {
> > 'id-123' => {
> > 'content' => 'b'
> > }
> > }
> > }
> > };
> >
> > Anyway, I wonder if this module should be marked as "discouraged".
> > After all it's a clone if XML::Simple, and that module has in the
> > meantime this notice:
> >
https://metacpan.org/pod/XML::Simple#STATUS-OF-THIS-MODULE
>
Show quoted text> I am using XML::LibXML::Simple, this module is not deprecated. [...]
"discouraged" is not an alias of "deprecated".
Yes, it is much, much preferred to process XML with a schema: in that
case, you can optimize the Perl representation of the XML data in a
predictable way.
XML::Simple is a module with a (too?) high level of dwimmery, in the
Perl tradition. And that makes it easy to shoot yourself in your foot
using it. The manual is long, and you must read most of it to understand
all foot-angles. Dwimmery, on the other hand, also shows what people
needed as functionality of time. XML::LibXML::Simple attempts to be
bugwards compatible with that interface.
You are hurt by the default use of KeyAttr, which automatically converts
items with attributes 'name', 'key', or 'id' into HASHes. This is a good
guess in the common sense. For instance, the 'id' attribute is nearly
always of ID-type as defined in W3C-schema's, which are required to be
unique for the document.
So: the easy work-around for you is to change the KeyAttr list. That's
not a bug: it is described in the manual and follows common practice in
the real world.
Show quoted text> My code demo does use warnings.
> "-w is the older version of the use warnings pragma,
> which is preferred nowadays. While -w is global, use
> warnings is lexical, and can be activated selectively."
Yes, I never use '-w' myself. XML::LibXML::Simple started with a pure
code copy of XML::Simple, but rewriting the DOM handling. The original
module used "warn '...' if $^W" a lot, where $^W is directly related to
the '-w' command-line flag, not to 'no warnings'.
I am considering now replacing the use of $^W for a clean warning class.
--
Regards,
MarkOv
------------------------------------------------------------------------
Mark Overmeer MSc MARKOV Solutions
Mark@Overmeer.net solutions@overmeer.net
http://Mark.Overmeer.net http://solutions.overmeer.net