I'm validating some xml files with the following xml schema:
String xsdMarkup = "[...] <xsd:complexType name='connectionType'> <xsd:attribute name='SourceElement' type='guidType' use='required' /> <xsd:attribute name='TargetElement' type='guidType' use='required' /> <xsd:attribute name='GUID' type='guidType' use='required' /> <xsd:assert test='@SourceElement == 0' /> </xsd:complexType> [...] "; XmlSchemaSet schemas = new XmlSchemaSet(); schemas.Add("", XmlReader.Create(new StringReader(xsdMarkup))); Console.WriteLine("Validating doc ..."); docToValidate.Validate(schemas, (sender, e) => { Console.WriteLine(e.Message); valid = false; }, true); I just wanted to introduce some assert tags in order to have more powerful validation. But this leads to the exception:
System.Xml.Schema.XmlSchemaException: The http://www.w3.org/2001/XMLSchema:assert-element is not supported in this context.
What I don't know right now is whether...
- I used the assert-element in the wrong place inside the xsd
- The http://www.w3.org/2001/XMLSchema-Namespace doesn't support version 1.1 of XML Schema and thereby assert-elements
- C# XmlSchemaSet doesn't know how to deal with assert elements
Thanks for help in advance!