validateOnParse versus xsi:nil
Hi
I have a problem loading XML-documents that contain the xsi:nil-attribute in the following situation:
- XML-sample 'Simple.xml':
<?xml version="1.0" encoding="UTF-8" ?>
<Simple xmlns="http://www.simple.be/Simple"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<MyDate xsi:nil="true" />
</Simple>
- XML-sample 'Simple2.xml':
<?xml version="1.0" encoding="UTF-8" ?>
<Simple xmlns="http://www.simple.be/Simple"
xmlns:dummy="http://www.dummy.be/dummy">
<MyDate dummy:nil="true" />
</Simple>>
- (simplified) C++-code used to load the XML-document
MSXML2::IXMLDOMDocument2Ptr DOMPtr = NULL;
try
{
if (DOMPtr.CreateInstance (__uuidof (MSXML2::DOMDocument40)) !
= VARIANT_TRUE)
{
DOMPtr->async = VARIANT_FALSE;
DOMPtr->validateOnParse = VARIANT_FALSE;
if (DOMPtr->load ("Simple.xml") != VARIANT_TRUE)
{
...
}
}
}
catch (_com_error e)
{
...
}
The load fails when validateOnParse = VARIANT_FALSE with error 'xsi:nil attribute on element 'MyDate' is invalid' (code: -1072897995) and I have no clue why.
The MSXML-help for validateOnParse states the following:
'Boolean. The property is read/write. If True, it validates during parsing. If False, it parses only for well-formed XML. The default is True.'
If you set this property to 'True':
- What exactly is validated?
- What is it validated against?
And... why is there no problem when loading 'Simple2.xml'?
Kind regards
JaKKe
|