I've tried to revrite a JScript example at MSDN in order to validate XML against certain schemas.
As a first attmempt, I've used the sl-valid.xml, sl-notValid.xml, and sl.xsd files as used in the example.
My code goes as follows:
procedure BasicValidation(FileName: string);
var
XML: IXMLDOMDocument2;
begin
// Load XML and resolve externals
XML := ComsDOMDocument.Create;
XML.async := False;
XML.validateOnParse := True;
XML.resolveExternals := True;
XML.setProperty('SelectionLanguage', 'XPath');
XML.setProperty('SelectionNamespaces', 'xmlns:x=''urn:book''');
XML.load(FileName);
if XML.parseError.errorCode <> 0 then
ShowMessage('Error parsing. Reason: ' + XML.parseError.reason)
else
ShowMessage('XML validation OK.');
end;
When I try the sl-notValid.xml file, I still get 'XML validation OK'. Have anyone seen this before? What's the fundamental difference between the above code and that of the JScript examle http://msdn.microsoft.com/en-us/library/ms764717%28VS.85%29.aspx ?