You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by am...@apache.org on 2009/08/10 18:25:04 UTC
svn commit: r802846 - in /xerces/c/trunk: src/xercesc/validators/schema/
tests/src/XSTSHarness/regression/
tests/src/XSTSHarness/regression/XERCESC-697/
Author: amassari
Date: Mon Aug 10 16:25:03 2009
New Revision: 802846
URL: http://svn.apache.org/viewvc?rev=802846&view=rev
Log:
Before assuming that a complex type has a simple type as base type simply because it has a data type validator, inspect the base type definition (XERCESC-697)
Added:
xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-697/
xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-697/base.xsd
xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-697/redefined.xml
xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-697/redefined.xsd
Modified:
xerces/c/trunk/src/xercesc/validators/schema/TraverseSchema.cpp
xerces/c/trunk/tests/src/XSTSHarness/regression/Xerces.testSet
Modified: xerces/c/trunk/src/xercesc/validators/schema/TraverseSchema.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/schema/TraverseSchema.cpp?rev=802846&r1=802845&r2=802846&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/schema/TraverseSchema.cpp (original)
+++ xerces/c/trunk/src/xercesc/validators/schema/TraverseSchema.cpp Mon Aug 10 16:25:03 2009
@@ -3710,9 +3710,21 @@
const XMLCh* prefix = getPrefix(baseName);
const XMLCh* localPart = getLocalPart(baseName);
const XMLCh* uri = resolvePrefixToURI(simpleContent, prefix);
- DatatypeValidator* baseValidator = getDatatypeValidator(uri, localPart);
- if (baseValidator != 0) {
+ // check for 'anyType'
+ if (XMLString::equals(uri, SchemaSymbols::fgURI_SCHEMAFORSCHEMA)
+ && XMLString::equals(localPart, SchemaSymbols::fgATTVAL_ANYTYPE)) {
+
+ reportSchemaError(simpleContent, XMLUni::fgXMLErrDomain, XMLErrs::InvalidSimpleContentBase, baseName);
+ throw TraverseSchema::InvalidComplexTypeInfo;
+ }
+
+ processBaseTypeInfo(simpleContent, baseName, localPart, uri, typeInfo);
+
+ ComplexTypeInfo* baseTypeInfo = typeInfo->getBaseComplexTypeInfo();
+ DatatypeValidator* baseValidator = typeInfo->getBaseDatatypeValidator();
+
+ if (baseValidator != 0 && baseTypeInfo == 0) {
// check that the simpleType does not preclude derivation by extension
if ((baseValidator->getFinalSet() & SchemaSymbols::XSD_EXTENSION) == typeInfo->getDerivedBy()) {
@@ -3722,25 +3734,16 @@
throw TraverseSchema::InvalidComplexTypeInfo;
}
- typeInfo->setBaseComplexTypeInfo(0);
- typeInfo->setBaseDatatypeValidator(baseValidator);
- }
- else {
-
- // check for 'anyType'
- if (XMLString::equals(uri, SchemaSymbols::fgURI_SCHEMAFORSCHEMA)
- && XMLString::equals(localPart, SchemaSymbols::fgATTVAL_ANYTYPE)) {
+ //Schema Spec: 5.11: Complex Type Definition Properties Correct: 2
+ if (typeInfo->getDerivedBy() == SchemaSymbols::XSD_RESTRICTION) {
- reportSchemaError(simpleContent, XMLUni::fgXMLErrDomain, XMLErrs::InvalidSimpleContentBase, baseName);
+ reportSchemaError(simpleContent, XMLUni::fgXMLErrDomain, XMLErrs::InvalidComplexTypeBase, baseName);
throw TraverseSchema::InvalidComplexTypeInfo;
}
-
- processBaseTypeInfo(simpleContent, baseName, localPart, uri, typeInfo);
}
// check that the base isn't a complex type with complex content
// and that derivation method is not included in 'final'
- ComplexTypeInfo* baseTypeInfo = typeInfo->getBaseComplexTypeInfo();
bool simpleTypeRequired = false;
if (baseTypeInfo) {
@@ -3771,15 +3774,8 @@
// -----------------------------------------------------------------------
if (typeInfo->getDerivedBy() == SchemaSymbols::XSD_RESTRICTION) {
- //Schema Spec: 5.11: Complex Type Definition Properties Correct: 2
- if (typeInfo->getBaseDatatypeValidator() != 0) {
-
- reportSchemaError(simpleContent, XMLUni::fgXMLErrDomain, XMLErrs::InvalidComplexTypeBase, baseName);
- throw TraverseSchema::InvalidComplexTypeInfo;
- }
- else {
- typeInfo->setBaseDatatypeValidator(baseTypeInfo->getDatatypeValidator());
- }
+ if(baseTypeInfo)
+ typeInfo->setBaseDatatypeValidator(baseTypeInfo->getDatatypeValidator());
if (content != 0) {
Added: xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-697/base.xsd
URL: http://svn.apache.org/viewvc/xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-697/base.xsd?rev=802846&view=auto
==============================================================================
--- xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-697/base.xsd (added)
+++ xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-697/base.xsd Mon Aug 10 16:25:03 2009
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <xsd:complexType name="AddressType" abstract="true">
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string">
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+ <xsd:complexType name="MyAddressType">
+ <xsd:simpleContent>
+ <xsd:restriction base="AddressType">
+ <xsd:enumeration value="BillingAddress"/>
+ <xsd:enumeration value="DataBackupStorageAddress"/>
+ <xsd:enumeration value="DuplicateRecordsAddress"/>
+ <xsd:enumeration value="FurthestTerminalAddress"/>
+ <xsd:enumeration value="GaragingAddress"/>
+ <xsd:enumeration value="MailingAddress"/>
+ <xsd:enumeration value="PointOfDepartureAddress"/>
+ <xsd:enumeration value="PointOfDestinationAddress"/>
+ <xsd:enumeration value="PreviousAddress"/>
+ <xsd:enumeration value="ShippingAddress"/>
+ <xsd:enumeration value="SoftwareBackupStorageAddress"/>
+ <xsd:enumeration value="StreetAddress"/>
+ </xsd:restriction>
+ </xsd:simpleContent>
+ </xsd:complexType>
+</xsd:schema>
\ No newline at end of file
Added: xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-697/redefined.xml
URL: http://svn.apache.org/viewvc/xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-697/redefined.xml?rev=802846&view=auto
==============================================================================
--- xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-697/redefined.xml (added)
+++ xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-697/redefined.xml Mon Aug 10 16:25:03 2009
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="redefined.xsd">StreetAddress</root>
Added: xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-697/redefined.xsd
URL: http://svn.apache.org/viewvc/xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-697/redefined.xsd?rev=802846&view=auto
==============================================================================
--- xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-697/redefined.xsd (added)
+++ xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-697/redefined.xsd Mon Aug 10 16:25:03 2009
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <xsd:redefine schemaLocation="base.xsd">
+ <xsd:complexType name="MyAddressType">
+ <xsd:simpleContent>
+ <xsd:restriction base="MyAddressType">
+ <xsd:enumeration value="BillingAddress"/>
+ <xsd:enumeration value="GaragingAddress"/>
+ <xsd:enumeration value="MailingAddress"/>
+ <xsd:enumeration value="StreetAddress"/>
+ </xsd:restriction>
+ </xsd:simpleContent>
+ </xsd:complexType>
+ </xsd:redefine>
+ <xsd:element name="root" type="MyAddressType"/>
+</xsd:schema>
\ No newline at end of file
Modified: xerces/c/trunk/tests/src/XSTSHarness/regression/Xerces.testSet
URL: http://svn.apache.org/viewvc/xerces/c/trunk/tests/src/XSTSHarness/regression/Xerces.testSet?rev=802846&r1=802845&r2=802846&view=diff
==============================================================================
--- xerces/c/trunk/tests/src/XSTSHarness/regression/Xerces.testSet (original)
+++ xerces/c/trunk/tests/src/XSTSHarness/regression/Xerces.testSet Mon Aug 10 16:25:03 2009
@@ -86,7 +86,23 @@
<current status="accepted" date="2008-02-13"/>
</instanceTest>
</testGroup>
- <testGroup name="XERCESC-711">
+ <testGroup name="XERCESC-697">
+ <annotation>
+ <documentation>Incorrect Schema Validation Failure When Redefining Complex Type with Simple Content</documentation>
+ </annotation>
+ <documentationReference xlink:href="https://issues.apache.org/jira/browse/XERCESC-697"/>
+ <schemaTest name="XERCESC-697">
+ <schemaDocument xlink:href="./XERCESC-697/redefined.xsd"/>
+ <expected validity="valid"/>
+ <current status="accepted" date="2009-08-10"/>
+ </schemaTest>
+ <instanceTest name="XERCESC-697">
+ <instanceDocument xlink:href="./XERCESC-697/redefined.xml"/>
+ <expected validity="valid"/>
+ <current status="accepted" date="2009-08-10"/>
+ </instanceTest>
+ </testGroup>
+ <testGroup name="XERCESC-711">
<annotation>
<documentation>Validator doesn't enforce xsd:key</documentation>
</annotation>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org