DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20471>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20471

SAXParseException derivation-ok-restriction.2.2 when using XMLSchema restriction

           Summary: SAXParseException derivation-ok-restriction.2.2 when
                    using XMLSchema restriction
           Product: Xerces2-J
           Version: 2.4.0
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: XML Schema Structures
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


When parsing the XML file below with a SAX Parser, Xerces generates the 
following error :
org.xml.sax.SAXParseException: Schema error: ComplexType 'OrderType': 
derivation-ok-restriction.2.2:  Attribute 'number' has a target namespace which 
is not valid with respect to a base type definition's wildcard or, the base 
does not contain a wildcard.
        at org.apache.xerces.framework.XMLParser.reportError
(XMLParser.java:1204)
        at org.apache.xerces.validators.schema.TraverseSchema.reportSchemaError
(TraverseSchema.java:8899)
        at 
org.apache.xerces.validators.schema.TraverseSchema.reportGenericSchemaError
(TraverseSchema.java:8886)
        at 
org.apache.xerces.validators.schema.TraverseSchema.handleComplexTypeError
(TraverseSchema.java:3975)
        at 
org.apache.xerces.validators.schema.TraverseSchema.traverseComplexTypeDecl
(TraverseSchema.java:3434)
        at 
org.apache.xerces.validators.schema.TraverseSchema.traverseComplexTypeDecl
(TraverseSchema.java:3257)
        at org.apache.xerces.validators.schema.TraverseSchema.doTraverseSchema
(TraverseSchema.java:739)
        at org.apache.xerces.validators.schema.TraverseSchema.<init>
(TraverseSchema.java:540)
        at org.apache.xerces.validators.common.XMLValidator.resolveSchemaGrammar
(XMLValidator.java:2783)
        at org.apache.xerces.validators.common.XMLValidator.parseSchemas
(XMLValidator.java:2669)
        at 
org.apache.xerces.validators.common.XMLValidator.bindNamespacesToElementAndAttri
butes(XMLValidator.java:2551)
        at org.apache.xerces.validators.common.XMLValidator.callStartElement
(XMLValidator.java:1152)
        at org.apache.xerces.framework.XMLDocumentScanner.scanElement
(XMLDocumentScanner.java:1806)
        at 
org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch
(XMLDocumentScanner.java:949)
        at org.apache.xerces.framework.XMLDocumentScanner.parseSome
(XMLDocumentScanner.java:381)
        at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1081)
        at com.testfb.TestXercesBugs.main(TestXercesBugs.java:31)

This error occurs only when :
 - the base type and the restricted type are in different namespaces
 - the base type contains at least one attribute
 - the base type contains at least one element containing one attribute
It seems strange to me. Since I does not find any error in the chema 
definitions, I assume that it could be a Xerces 2.4.0 bug


the XMLSchema base.xsd :
---------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="http://www.datamodel.testfb.com/base"; 
xmlns="http://www.w3.org/2001/XMLSchema"; 
xmlns:base="http://www.datamodel.testfb.com/base"; >
        
        
        <complexType name="OrderType">
                <sequence>
                        <element name="leg" type="base:LegType" minOccurs="0"/>
                </sequence>
                <attribute name="quantity" type="string" use="optional"/>
        </complexType>
        
        <complexType name="LegType">
                <attribute name="number" type="string" use="optional"/>
        </complexType>


        
</schema>
---------------------------------------------------------------------

the XMLSchema restr.xsd :
---------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="http://www.datamodel.testfb.com/restr"; 
xmlns:restr="http://www.datamodel.testfb.com/restr"; 
xmlns:base="http://www.datamodel.testfb.com/base"; 
xmlns="http://www.w3.org/2001/XMLSchema"; >
        <import namespace="http://www.datamodel.testfb.com/base"; 
schemaLocation="base.xsd"/>
        
        <complexType name="OrderType">
                <complexContent>
                        <restriction base="base:OrderType">
                                <sequence>
                                        <element name="leg" type="base:LegType" 
minOccurs="0"/>
                                </sequence>
                                <attribute name="quantity" type="string" 
use="optional"/>
                        </restriction>
                </complexContent>
        </complexType>
        
        <element name="Order" type="restr:OrderType"/>
        
</schema>
---------------------------------------------------------------------

the XML file :
---------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<restr:Order xmlns:restr="http://www.datamodel.testfb.com/restr"; 
xmlns:base="http://www.datamodel.testfb.com/base"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://www.datamodel.testfb.com/restr restr.xsd"  >
        <leg number="05"/>
</restr:Order>
---------------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to