[JIRA] Created: (JAXB-1025) Single schema works but not multiple schema

  • From: "lulseged (JIRA)" <jira-no-reply@...>
  • To: issues@...
  • Subject: [JIRA] Created: (JAXB-1025) Single schema works but not multiple schema
  • Date: Sat, 7 Jun 2014 13:35:49 +0000 (UTC)
  • Auto-submitted: auto-generated

Single schema works but not multiple schema
-------------------------------------------

                 Key: JAXB-1025
                 URL: https://java.net/jira/browse/JAXB-1025
             Project: jaxb
          Issue Type: Bug
    Affects Versions: 2.2.7
         Environment: windows 8.1 Enterprise
            Reporter: lulseged
            Assignee: Iaroslav Savytskyi


Validation works with single schema but does not work with multiple schema. 
Java objects created by xjc are same. My tests works when it is a single 
schema but gives validation error when I use multiple schema, cvc-elt.1: 
Cannot find the declaration of element 'itinerary'.

There is no single difference between single and multiple schema except it is 
divided in number of schemas.

Why is validation failing?

I have used 2.2.7 and 2.2.11-SNAPSHOT. Gives the same error.

I can provide a maven project that can demonstrate this case.

I will appreciate any help.

BR
Lulseged
 

For single:

Source source = new 
StreamSource(getClass().getResourceAsStream("/xsd/itinerary.xsd");

For multiple:
Source[] source = new StreamSource[]
{
        new StreamSource(getClass().getResourceAsStream("/xsd/travel.xsd")),
        new StreamSource(getClass().getResourceAsStream("/xsd/plane.xsd")),
        new StreamSource(getClass().getResourceAsStream("/xsd/itinerary.xsd"))
};


Schema schema = schemaFactory.newSchema(source);

When using 

Single schema:
itinerary.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" ;
xmlns:e="http://example.org/" targetNamespace="http://example.org/";
        elementFormDefault="qualified" attributeFormDefault="qualified">

        <xsd:element name="travel" type="e:travel-type" />

        <xsd:complexType name="travel-type" abstract="true">
                <xsd:sequence>
                        <xsd:element name="origin" type="xsd:string" />
                        <xsd:element name="destination" type="xsd:string" />
                </xsd:sequence>
        </xsd:complexType>

        <!-- plane -->
        <xsd:element name="plane" type="e:plane-type" 
substitutionGroup="e:travel" />

        <xsd:complexType name="plane-type">
                <xsd:complexContent>
                        <xsd:extension base="e:travel-type">
                                <xsd:sequence>
                                        <xsd:element name="flightNumber" 
type="xsd:int" />
                                        <xsd:element name="meal" 
type="xsd:string" />
                                </xsd:sequence>
                        </xsd:extension>
                </xsd:complexContent>
        </xsd:complexType>

        <!-- itinerary -->
        <xsd:element name="itinerary" type="e:itinerary-type" />

        <xsd:complexType name="itinerary-type">
                <xsd:sequence>
                        <xsd:element ref="e:travel" maxOccurs="unbounded" />
                </xsd:sequence>
        </xsd:complexType>

</xsd:schema>

Multiple schema:
travel.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" ;
xmlns:e="http://example.org/" targetNamespace="http://example.org/";
        elementFormDefault="qualified" attributeFormDefault="qualified">

        <xs:element name="travel" type="e:travel-type" />

        <xs:complexType name="travel-type" abstract="true">
                <xs:sequence>
                        <xs:element name="origin" type="xs:string" />
                        <xs:element name="destination" type="xs:string" />
                </xs:sequence>
        </xs:complexType>

</xs:schema>

itinerary.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" ;
xmlns:e="http://example.org/" xmlns="http://example.org/";
        targetNamespace="http://example.org/" elementFormDefault="qualified";>

        <xs:include schemaLocation="travel.xsd" />

        <xs:include schemaLocation="plane.xsd" />

        <xs:element name="itinerary" type="e:itinerary-type" />

        <xs:complexType name="itinerary-type">
                <xs:sequence>
                        <xs:element ref="e:travel" maxOccurs="unbounded" />
                </xs:sequence>
        </xs:complexType>
</xs:schema>

plane.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" ;
xmlns:e="http://example.org/" targetNamespace="http://example.org/";
        elementFormDefault="qualified" attributeFormDefault="qualified">

        <xs:include schemaLocation="travel.xsd" />

        <xs:element name="plane" type="e:plane-type" 
substitutionGroup="e:travel" />

        <xs:complexType name="plane-type">
                <xs:complexContent>
                        <xs:extension base="e:travel-type">
                                <xs:sequence>
                                        <xs:element name="flightNumber" 
type="xs:int" />
                                        <xs:element name="meal" 
type="xs:string" />
                                </xs:sequence>
                        </xs:extension>
                </xs:complexContent>
        </xs:complexType>
</xs:schema>




-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
https://java.net/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


[JIRA] Created: (JAXB-1025) Single schema works but not multiple schema

lulseged (JIRA) 06/07/2014
Terms of Use; Privacy Policy; Copyright ©2013-2017 (revision 20160708.bf2ac18)
 
 
Close
loading
Please Confirm
Close