[
https://issues.apache.org/jira/browse/XERCESC-1952?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14029035#comment-14029035
]
Martin Raiber commented on XERCESC-1952:
----------------------------------------
We had this problem as well.
Attached is a patch for the issue. Please review.
The patch contains appropriate test cases.
Xerces will not have validation errors in xsd:any types (if validation is
skipped) anymore, if nillable types are not empty. This is consistent with
other XML validators.
I changed the fNil-boolean to a variable counting the number of elements with
nillable-attribute true, as otherwise an element with nillable attribute will
reset the nillable state of its parent element. A test case for that is
included.
A better solution would be to handle the nillable attribute exclusively in the
Validator and not in the parser, but this would require more extensive changes.
I guess handling this by setting a boolean in the validator from the parser was
done because of performance?
> Different validation results for different empty element syntax: <e
> xsi:nil="true" /> vs. <e xsi:nil="true"></e>
> ----------------------------------------------------------------------------------------------------------------
>
> Key: XERCESC-1952
> URL: https://issues.apache.org/jira/browse/XERCESC-1952
> Project: Xerces-C++
> Issue Type: Bug
> Components: Validating Parser (XML Schema)
> Affects Versions: 3.1.1
> Environment: Windows Vista
> Reporter: Alexey Miroshnichenko
> Attachments: note.xml, note.xsd, xerces-nillable2.patch
>
>
> In case of <e xsi:nil="true"></e> syntax for empty element used, XSD
> validation reports follow message
> Message: element 'subitem' is nil and must be empty
> In case empty element defined as <e xsi:nil="true" /> there is no validation
> error.
> XML file:
> ===
> <?xml version="1.0"?>
> <note xmlns="http://www.test"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.test note.xsd">
> <item>
> <subitem>
> <A>text1</A>
> <e xsi:nil="true"></e>
> <C>text2</C>
> </subitem>
> </item>
> </note>
> ===
> XSD file:
> ===
> <?xml version="1.0"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns="http://www.test"
> elementFormDefault="qualified"
> targetNamespace="http://www.test">
> <xs:element name="note">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="item">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="subitem" nillable="true"
> type="xs:anyType" minOccurs="0" />
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:schema>
> ===
--
This message was sent by Atlassian JIRA
(v6.2#6252)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]