Reputation: 279
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...
Thanks for help in advance!
Upvotes: 6
Views: 3887
Reputation: 11953
The .NET implementation of XSD schemas handle only version 1.0 and not version 1.1 - hence it does not support assert
.
Upvotes: 8