Skip Menu |

This queue is for tickets about the XML-Compile CPAN distribution.

Report information
The Basics
Id: 34597
Status: resolved
Priority: 0/
Queue: XML-Compile

People
Owner: Nobody in particular
Requestors: ANDK [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.72
Fixed in: (no value)



Subject: Surprise when calling $reader in list context
Today I got a surprising result when I called a reader in list context. It did not return the hash I expected but instead returned two scalars where the second was the result I wanted. Illustrated in the following example. Did I not read enough of the Fine Manual or is it unintended? This is the program: use strict; use warnings; use XML::LibXML; use XML::Compile::Schema; my $parser = XML::LibXML->new; my $msg = $parser->parse_string(<<'EOS'); <?xml version="1.0" encoding="utf-8"?><Foo bar="Bar1"/> EOS my $top = $msg->documentElement; my $xsd = $parser->parse_string(<<'EOS'); <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="Foo"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" maxOccurs="unbounded" ref="RecentFlurbls"/> </xs:sequence> <xs:attribute name="bar"/> </xs:complexType> </xs:element> <xs:element name="RecentFlurbls"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" maxOccurs="unbounded" ref="Flurbl"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="Flurbl"> <xs:complexType> <xs:attribute name="name"/> </xs:complexType> </xs:element> </xs:schema> EOS my $schema = XML::Compile::Schema->new(); $schema->addSchemas($xsd); my $read = $schema->compile(READER => 'Foo'); my $scalar = $read->($top); my @list = $read->($top); require Data::Dumper; print Data::Dumper::Dumper({scalar => $scalar, list => \@list}); and this is its output: $VAR1 = { 'scalar' => { 'bar' => 'Bar1' }, 'list' => [ 'Foo', { 'bar' => 'Bar1' } ] };
Subject: Re: [rt.cpan.org #34597] Surprise when calling $reader in list context
Date: Wed, 2 Apr 2008 09:18:42 +0200
To: Andreas Koenig via RT <bug-XML-Compile [...] rt.cpan.org>
From: Mark Overmeer <mark [...] overmeer.net>
* Andreas Koenig via RT (bug-XML-Compile@rt.cpan.org) [080401 16:40]: Show quoted text
> Queue: XML-Compile > Subject: Surprise when calling $reader in list context > Broken in: 0.72 > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=34597 > > > Today I got a surprising result when I called a reader in list > context.
Also unexpected for me lib/XML/Compile/Schema/XmlReader.pm: sub element_wrapper ... - $processor->($tree); + ($processor->($tree))[-1]; -- Thanks for the bug-report, MarkOv ------------------------------------------------------------------------ Mark Overmeer MSc MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net
Fixed in 0.73 This was the source of a few surprises in other parts of the code, which did improve the whole. Thanks Andreas! (pitty you couldn't come to Oslo)