[Xml-compile] Problem to write repeatable blocks
Alex Bernier
alex.bernier at free.fr
Tue Sep 10 08:39:53 GMT 2013
Hello,
I have some issues when trying to use to produce "Repetative blocks" with XML-Compile.
I would like to produce the following XML output :
<questions>
<inputQuestion id="q1">
<inputTypes>
<input type="TEXT_ALPHANUMERIC"/>
</inputTypes>
<label xml:lang="en"><text>Choice 1</text></label>
</inputQuestion>
<inputQuestion id="q2">
<inputTypes>
<input type="TEXT_ALPHANUMERIC"/>
</inputTypes>
<label xml:lang="en"><text>Choice 2</text></label>
</inputQuestion>
</questions>
I use the following Perl syntax (as a result of a SOAP operation) :
return +{ questions =>
{
cho_inputQuestion =>
[
inputQuestion => { id=>'q1',
inputTypes => {
input => { type => 'TEXT_ALPHANUMERIC' }
},
label => { lang=>'en', text => 'Choice 1' }
},
inputQuestion => { id=>'q2',
inputTypes => {
input => { type => 'TEXT_ALPHANUMERIC' }
},
label => { lang=>'en', text => "Choice 2" }
}
]
}
};
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
I paste a part of the Schema below.
Is the syntax I use incorrect ?
How can I fix this ?
Regards,
Alex
The Schema:
<xs:element name="questions">
<xs:complexType>
<xs:choice>
<xs:choice minOccurs="1" maxOccurs="unbounded">
<xs:element ref="multipleChoiceQuestion"/>
<xs:element ref="inputQuestion"/>
</xs:choice>
<xs:element name="contentListRef" type="xs:NMTOKEN"/>
<xs:element ref="label"/>
</xs:choice>
</xs:complexType>
</xs:element>
<xs:element name="multipleChoiceQuestion">
...
</xs:element>
<xs:element name="inputQuestion">
<xs:complexType>
<xs:sequence>
<xs:element name="inputTypes" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element ref="input" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element ref="label" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
<xs:attribute name="id" type="xs:NMTOKEN" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="input">
<xs:complexType>
<xs:attribute name="type" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="TEXT_NUMERIC"/>
<xs:enumeration value="TEXT_ALPHANUMERIC"/>
<xs:enumeration value="AUDIO"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="label">
<xs:complexType>
<xs:sequence>
<xs:element name="text" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:element name="audio" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:attribute name="uri" type="xs:anyURI" use="required"/>
<xs:attribute name="rangeBegin" type="xs:long" use="optional"/>
<xs:attribute name="rangeEnd" type="xs:long" use="optional"/>
<xs:attribute name="size" type="xs:long" use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute ref="xml:lang" use="required"/>
<xs:attribute name="dir" use="optional">
...
</xs:attribute>
</xs:complexType>
</xs:element>
More information about the Xml-compile
mailing list