13

I am trying to use the following in an XSD

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" >
<xs:element name="dimension">
  <xs:complexType>
    <xs:attribute name="height" type="xs:int"/>
    <xs:attribute name="width" type="xs:int"/>
    <xs:assert test="@height = @width"/>
  </xs:complexType>
</xs:element>

I know assert/assertion are part of XML Schema 1.1 but not 1.0. However everything I have read indicates the namespace is the same for both: http://www.w3.org/2001/XMLSchema

A minor problem is that the program I am using to write the Schema (Microsoft Visual Studio) does not recognize the 'assert' element, saying the 'the element complexType in namespace (...) has invalid child element 'assert'.

The main problem is that when I actually try to validate an XML against this schema, using xmllint, it throws up an error saying

" element assert: Schemas parser error : Element '{http://www.w3.org/2001/XMLSchema}complexType': The content is not valid. Expected is (annotation?, (simpleContent | complexContent | ((group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?))))

Is 1.1 simply not recognized by xmllint/visual studio, despite being pointed to the 1.1 namespaces?

Petru Gardea
  • 21,373
  • 2
  • 50
  • 62
user2197116
  • 667
  • 3
  • 8
  • 21

1 Answers1

21

To process an XSD 1.1 schema you need an XSD 1.1 schema processor. Microsoft does not supply one (they seem to have given up implementing new W3C XML specifications). As far as I am aware the only XSD 1.1 processor available on the .NET platform is Saxonica's.

james.garriss
  • 12,959
  • 7
  • 83
  • 96
Michael Kay
  • 156,231
  • 11
  • 92
  • 164
  • Thank you! I am new to xml schema, but would have thought the processor would just pull down the latest definition from the namespace you point it to. Are there any 1.1 XSD compatible editors for linux? – user2197116 Mar 25 '13 at 17:33
  • 2
    No, you can't expect a processor developed in 1994 to implement a specification published in 2013. oXygen is an editor that runs on linux and supports XSD 1.1 – Michael Kay Mar 26 '13 at 18:23
  • Oxygen does not support 1.1, it is throwing error on assert and assertion. I am running eclipse oxygen on ubuntu 16 linux so I am also facing the same issue. – prem30488 Oct 01 '18 at 12:25
  • 2
    oXygen does support XSD 1.1 see for example https://www.oxygenxml.com/doc/versions/20.1/ug-editor/topics/schema-1-1-support.html – Michael Kay Oct 01 '18 at 14:28