Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
3.1.2
-
None
-
None
-
Linux Intel 64 Bit
Description
Issue 1187 not completely resolved.
The following modification to that issue shows that when xsi:nil="true" is encountered within an <any> section in a top level element, the parser complains that the entire node should be empty.
schema:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.w3schools.com"
elementFormDefault="qualified"
targetNamespace="http://www.w3schools.com">
<xs:element name="note">
<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:any namespace="##any" processContents="skip" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
example:
<?xml version="1.0"?>
<note xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3schools.com note.xsd">
<to>Tove</to>
<from>Jani</from>
<school>
<student xsi:nil="true"/>
</school>
<random xsi:nil="true"></random>
</note>
result from schema validation:
../StdInParse -n -s < test.xml
Error at (file stdin, line 11, char 8): element 'note' is nil and must be empty
I debugged the issue within the IGXMLScanner code and know the root cause:
Internally, as attributes are scanned per element in the scanner method:
scanRawAttrListforNameSpaces() the validator object is modified when any xsi:nil="true" is encountered. This is normally fine when the actual element will be validated (i.e. fValidate == true) because the checkContent() method of the validator is called during the scanEndTag() method, resetting the state of fNil/fNilFound.
When fValidate == false (i.e. within a <any> tag with processContents="skip"), scanRawAttrListforNameSpaces continues to modify the fNil/fNilFound variables within the validator on an element by element case. Therefore if the last element in the <any> block has xsi:nil="true" when the final scanEndTag() for the parent element is called the state of the fNil/fNilFound variables in the validator are left incorrect.
I think the solution might be to store the fNil/fNilFound states within the element stack so that as scanEndTag calls fire off, the correct state is maintained.