[Xml-compile] Problem to write repeatable blocks

Mark Overmeer mark at overmeer.net
Tue Sep 10 10:57:38 GMT 2013


* Alex Bernier (alex.bernier at free.fr) [130910 10:40]:
> On Tue, Sep 10, 2013 at 12:11:09PM +0200, Mark Overmeer wrote:
> > The attached script demonstrates that it works when your data-structure
> > is correct. You forgot the cho_multipleChoiceQuestion level.
> 
> Thank you very much.
> 
> Regarding the syntax : I don't understand clearly why the
> "inputQuestion" elements should be included in a variable called
> "cho_multipleChoiceQuestion". Why "cho_inputQuestion => \@questions"
> produces invalid code ?

You should not (try to) think ;-)   $wsdl->template(PERL => $type)
produces what is expected, and you should follow that.

The problem is your nested <choice> does not have a name.  The XML
structure can not be mapped to a perl structure without a name, so
X::C constructs a name based on the first element inside the choice.
multipleChoiceQuestion is the name of the first element, hence
cho_multipleChoiceQuestion is the name of the choice block.  Even
if you only put other elements in there.

> Another question : which syntax should I use to produce output like
> <do:label xml:lang="en"> instead of <do:label lang="en"> ?

When you use a schema, you use schema data-types, so I do not expect
to see xml:lang where we have an xsd:language type.  However, it is
possible...  I see this:

  <xs:element name="label">
    <xs:complexType>
      <xs:sequence>
        ...
      </xs:sequence>
      <xs:attribute ref="xml:lang" use="required"/>

So, you "lang" parameter will get taken.  Whether the attribute is
included as 'lang' or 'xml:lang' depends on the attributeFormDefault
of the schema.

Your xml.xsd does not say attributeFormDefault="qualified", so it
defaults to "unqualified".  Old schema's often do not have these
*FromDefault lines in them, because they were added as syntax later.
You can fix that when loading the schema:

  $wsdl->importDefinitions('xml.xsd'
    , attribute_form_default => 'qualified'
    );

importDefinitions() calls addSchemas() which offers more of these
tunables.
-- 
Regards,

               MarkOv

------------------------------------------------------------------------
       Mark Overmeer MSc                                MARKOV Solutions
       Mark at Overmeer.net                          solutions at overmeer.net
http://Mark.Overmeer.net                   http://solutions.overmeer.net




More information about the Xml-compile mailing list