Re: [xml] Making sequence entries option in .xsd files.



On 06/06/2016 07:52 PM, Steve Underwood wrote:
Hi,

In the .xsd file for the DLMS Smart Grid protocol I find the following section:

<xsd:complexTypename="InitiateRequest">
<xsd:sequence>
<xsd:elementname="dedicated-key"minOccurs="0"type="xsd:hexBinary"/>
<xsd:elementname="response-allowed"default="true"type="xsd:boolean"/>
<xsd:elementname="proposed-quality-of-service"minOccurs="0"type="Integer8"/>
<xsd:elementname="proposed-dlms-version-number"type="Unsigned8"/>
<xsd:elementname="proposed-conformance"type="Conformance"/>
<xsd:elementname="client-max-receive-pdu-size"type="Unsigned16"/>
</xsd:sequence>
</xsd:complexType>

By the protocol definition, the first 3 items in that sequence should be optional. The minOccurs="0" elements cause items 1 and 3 to be correctly treated as optional. However, the parser in libxml2 2.9.3 treats the second item as a required element. Shouldn't the default setting act in a similar way to a minOccurs="0" element, in making the item optional? Is it always necessary to have minOccurs="0" present when default="something" is present, in order to actually implement the default?

Regards,
Steve
I have been reading the XSD spec again, and it seems to me the line
<xsd:elementname="response-allowed"default="true"type="xsd:boolean"/>
in the above XSD definition needs minOccurs="0" adding to it to make the element optional. I can't find anything in the spec that says default="xx" has any effect other than to set a default value.

Can anyone confirm or refute this?

Regards,
Steve


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]