#!/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',{ attribute_form_default => 'qualified'});
$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);

