[Xml-compile] Problem to write repeatable blocks
Mark Overmeer
solutions at overmeer.net
Tue Sep 10 10:11:09 GMT 2013
[back on-list]
* Alex Bernier (alex.bernier at free.fr) [130910 09:37]:
> On Tue, Sep 10, 2013 at 10:44:13AM +0200, Mark Overmeer wrote:
> > * Alex Bernier (alex.bernier at free.fr) [130910 08:37]:
> > > That produces the following error : alert: Can't
> > > use an undefined value as a HASH reference at
> > > /usr/local/share/perl/5.14.2/XML/Compile/Translate/Writer.pm line 339
The attached script demonstrates that it works when your data-structure
is correct. You forgot the cho_multipleChoiceQuestion level.
I'll see where it breaks for the illegal structure, but that does not
hinder you anymore.
--
Regards,
MarkOv
------------------------------------------------------------------------
Mark Overmeer MSc MARKOV Solutions
Mark at Overmeer.net solutions at overmeer.net
http://Mark.Overmeer.net http://solutions.overmeer.net
-------------- next part --------------
#!/usr/bin/env perl
use XML::Compile::WSDL11;
use XML::LibXML;
use Log::Report mode => 3;
my $wsdl = XML::Compile::WSDL11->new
( 'do-wsdl-10.wsdl'
, prefixes => [do => 'http://www.daisy.org/ns/daisy-online/']
);
# $wsdl->importDefinitions([glob "*.xsd"]);
$wsdl->importDefinitions('do-types-10.xsd');
$wsdl->importDefinitions('xml.xsd');
$wsdl->importDefinitions('dc.xsd');
$wsdl->importDefinitions('bookmark-2005-1.xsd');
$wsdl->importDefinitions('KeyExchange-2005-1.xsd');
$wsdl->importDefinitions('xenc-schema.xsd');
$wsdl->importDefinitions('xmldsig-core-schema.xsd');
print $wsdl->template(PERL => 'do:getQuestionsResponse');
my @questions;
push @questions,
+{ inputQuestion =>
{ id=>'q1'
, inputTypes => { input => { type => 'TEXT_ALPHANUMERIC' } }
, label => { lang=>'en', text => 'Choice 1' }
} };
push @questions,
+{ inputQuestion =>
{ id=>'q2'
, inputTypes => { input => { type => 'TEXT_ALPHANUMERIC' } }
, label => { lang=>'en', text => "Choice 2" }
} };
my $data = +{ questions => { cho_multipleChoiceQuestion => \@questions } };
my $doc = XML::LibXML::Document->new('1.0', 'UTF-8');
my $xml = $wsdl->writer('do:getQuestionsResponse')->($doc, $data);
print $xml->toString(1);
More information about the Xml-compile
mailing list