Re: Is the DLMS .xsd file correct?

Your assumption is correct.

The default value for an element applies when the element is empty, not when the element is absent.

Michael Kay
Saxonica


> On 8 Jun 2016, at 12:02, Steve Underwood <steveu@coppice.org> wrote:
> 
> Hi,
> 
> DLMS is a communications protocol for Smart Grid applications. At http://www.dlms.com/documentation/cosem-xml-representation/index.html there is an XSD file for the XML representation of DLMS. In this file can be found the following snippet:
> 
> <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 DLMS 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, with the parsers I have tried (e.g. libxml2) the second item is handled as a required element. From reading the XSD spec it seems that second item should contain minOccurs="0", because that is the only way to make items optional. I suspect someone has incorrectly assumed that default="true" makes the item optional, but I see nothing in the XSD spec to support that.
> 
> Can any XSD expert comment on this?
> 
> Regaards,
> Steve
> 
> 
> 
> 

Received on Wednesday, 8 June 2016 13:37:27 UTC