Re: Using assert in a complexType with complexContent

Michael Kay <[email protected]>
Newsgroups gmane.text.xml.schema.devel
Message-ID <[email protected]>
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
Saxonica
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.