perl - XML::Compile maxOccurs="1" seems unbounded -
i having trouble understanding output perl schema complier, appears in cases maxoccurs indicator ignored. if try use complex element more once, first reference seems correct, subsequent references output arrays when maxoccurs indicator set "1". started playing xml schemas, understanding limited.
i have following schema (sorry, tried cut down as possible):
<?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/xmlschema"> <xs:element name="top"> <xs:complextype> <xs:sequence> <xs:element ref="foo" minoccurs="0" maxoccurs="1"/> <xs:element ref="bar" minoccurs="0" maxoccurs="1"/> </xs:sequence> </xs:complextype> </xs:element> <xs:element name="foo"> <xs:complextype> <xs:sequence> <xs:element ref="bar" minoccurs="0" maxoccurs="1"/> </xs:sequence> </xs:complextype> </xs:element> <xs:element name="bar"> <xs:complextype> <xs:attribute name="baz" use="optional" /> </xs:complextype> </xs:element> </xs:schema>
when run:
perl -mxml::compile::schema -e 'print xml::compile::schema->new("example.xsd")->template("perl", "top");'
i following output:
# unnamed complex { # sequence of foo, bar # unnamed complex # optional foo => { # sequence of bar # unnamed complex # optional bar => { # xs:anytype # becomes attribute baz => "anything", }, }, # unnamed complex # complex structure shown above # optional bar => [{},], }
"bar" element of foo appears complex (as expected), "bar" under top level appears , list of complex, though maxoccurs="1" (not expecting). understanding wrong or schema incorrect?
the output array, in case it's limited size one. keep syntax accessing data consistent regardless of maxoccurs
value.
Comments
Post a Comment