Subject: | error: Can't coerce GLOB to string in entersub |
Date: | Wed, 20 May 2009 08:37:39 +0200 |
To: | bug-XML-Compile [...] rt.cpan.org |
From: | Erich Weigand <erich.weigand [...] nureg.de> |
Hello,
sorry, but I found another bug in XML::Compile. The error message is.
Can't coerce GLOB to string in entersub at /usr/share/perl5/XML/
Compile/Translate/Writer.pm line 790.
The perl script producing this error is
###################
#!/usr/bin/perl
use XML::Compile;
use XML::Compile::Schema;
my $content = {
language => 'de & en',
};
my $schema = XML::Compile::Schema->new( 'test.xsd' );
my $write = $schema->compile( WRITER => 'products' );
my $doc = XML::LibXML::Document->new();
my $xml = $write->( $doc, $content );
print $xml->toString( 1 )."\n";
###################
the xsd-file is
####################
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="products">
<xs:complexType>
<xs:attribute name="language" use="required"/>
</xs:complexType>
</xs:element>
</xs:schema>
####################
After changing the variable $content to
my $content = {
language => 'de & en',
};
the script works correct. So you can avoid this error by encoding all
unsafe characters to entities, but if you change the attribute to an
element this is done by the module.
I think the encoding of attribute should also be done automatically
by the module.
Best regards,
Erich Weigand
/// IT/Software-Entwicklung ///
NUREG GmbH ///
Dorfäckerstraße 31 | 90427 Nürnberg | Germany
Tel. +49-911-32002-203 | Fax +49-911-32002-299
Nürnberg HRB 22653 | USt.ID DE 814 685 653
Geschäftsführer: Michael Schmidt, Stefan Boas
www.nureg.de