W3C home > Mailing lists > Public > xmlschema-dev@w3.org > November 2011

Re: Using assert in a complexType with complexContent

From: Michael Kay <mike@saxonica.com>
Date: Fri, 04 Nov 2011 00:03:34 +0000
Message-ID: <4EB32BD6.8070006@saxonica.com>
To: xmlschema-dev@w3.org
On 03/11/2011 20:13, Costello, Roger L. wrote:
> Hi Folks,
> I got an error with the assert element in this complexType:
>      <xs:complexType name="authorType" mixed="true">
>          <xs:complexContent>
>              <xs:extension base="property">
>                  <xs:sequence>
>                      <xs:element ref="Person" />
>                  </xs:sequence>
>              </xs:extension>
>          </xs:complexContent>
>          <xs:assert test="not(normalize-space(string-join((.)/text(), '')))" />
>      </xs:complexType>
> The error message says:
>     Element xs:assert cannot appear here: expected no more elements
> I thought that it was legal to position the assert there? Apparently not. What is the proper way to do this?
> /Roger
'assert' can appear as the last child of 'extension'.

I'm afraid that the logic of the syntax for complex types defeats me 
totally - don't ask me to explain it, let alone to justify it. I'm not 
really sure why we allow assert to appear on types derived by extension, 
since the effect of assert is to restrict rather than to extend; I 
suppose one can justify it on the grounds that you might want to impose 
constraints on the content of the extension.

Michael Kay
Received on Friday, 4 November 2011 08:43:36 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:19 UTC