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=9651>.
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=9651

Cross-schema substitutionGroup not recognized

           Summary: Cross-schema substitutionGroup not recognized
           Product: Xerces2-J
           Version: 2.0.1
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: Major
          Priority: Other
         Component: XML Schema Structures
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


The goal is to have two separate schemas, with elements in one being 
substituted for elements of the other.  I'v boiled it down to the following 
example:

Schema alpha declares zim and foo, with a zim containing a foo.  Schema beta 
imports alpha and declares foobeta in the substitution group of foo.  I then 
try the following documSchema alpha declares zim and foo, with a zim 
containing a foo.  Schema beta imports alpha and declares foobeta in the 
substitution group of foo.  I then try the following document 
<alpha:zim><beta:foobeta/></alpha:zim>.  This fails with the following:  
[Error] gamma.xml:5:158: cvc-complex-type.2.4.a: Invalid content starting with 
e
lement 'be:foobeta'. The content must match '("alpha":foo)'.

After playing around, I found that this would work if I amended alpha to 
<import> beta.  That is _not_ a solution, as alpha is not generally 
updateable, and it is not possible to know how many other schemas are 
importing it.  This is a major issue for using Xerces in a distributed 
environment.

The three files (two schemas and example doc) follow:

<schema targetNamespace="alpha" xmlns:me="alpha" 
        xmlns="http://www.w3.org/2001/XMLSchema"; 
elementFormDefault="unqualified">
<complexType name="foo">
  <sequence>
    <element name="bar" type="string" minOccurs="0"/>
  </sequence>
</complexType>
<element name="foo" type="me:foo"/>
<element name="zim">
  <complexType>
     <sequence>
        <element ref="me:foo"/>
     </sequence>
  </complexType>
</element>
</schema>


<schema targetNamespace="beta" xmlns:me="alpha" xmlns:be="beta"
        xmlns="http://www.w3.org/2001/XMLSchema"; 
elementFormDefault="unqualified">
<import namespace="alpha" schemaLocation="file:///c:/Xerces-J-bin.2.0.1/xerces-
2_0_1/alpha.xsd"/>
<complexType name="foobeta">
  <complexContent>
     <extension base="me:foo">
       <sequence>
         <element name="baz" type="string" minOccurs="0"/>
       </sequence>
     </extension>
  </complexContent>
</complexType>
<element name="foobeta" type="be:foobeta" substitutionGroup="me:foo"/>
</schema>

<?xml version="1.0" encoding="UTF-8"?>
<me:zim xmlns:me="alpha" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xmlns:xsd="http://www.w3.org/2001/XMLSchema";
        xmlns:be="beta"
        xsi:schemaLocation="alpha file:///c:/Xerces-J-bin.2.0.1/xerces-
2_0_1/alpha.xsd beta file:///c:/Xerces-J-bin.2.0.1/xerces-
2_0_1/beta.xsd"><be:foobeta><bar>abcde</bar></be:foobeta></me:zim>

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

Reply via email to