jaxb-ri icon indicating copy to clipboard operation
jaxb-ri copied to clipboard

Invalid Namespace set for Restrictions defined accross different Namespaces

Open Tomas-Kraus opened this issue 15 years ago • 9 comments

In my current project we use XML schema files to define a web service interface. Often a base object is defined in one schema file (see below testSuper.xsd) and a use case specific restriction is defined in another schema file (see below test.xsd).

The generated XML encodes the restricted element (requestType) in the namespace of the base object (http://example.org/super) instead of the namespace of the restricted object (http://example.org/sub). The following sample illustrates the XML generated by JAXB:

<ns2:TestNode xmlns="http://example.org/super" xmlns:ns2="http://example.org/sub"> ns2:category <requestType>REQUEST</requestType> </ns2:category> </ns2:TestNode>

This XML doesn't validate against the schema using Eclipse 3.4 schema validation. Whereas the following XML output validates and is about what I expected:

<ns2:TestNode xmlns="http://example.org/super" xmlns:ns2="http://example.org/sub"> ns2:category ns2:requestTypeREQUEST</ns2:requestType> </ns2:category> </ns2:TestNode>

The XML schema definitions:

testSuper.xsd

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://example.org/super" targetNamespace="http://example.org/super" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:complexType name="ObjectCategory"> xs:sequence <xs:element name="requestType" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:schema>

test.xsd

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://example.org/sub" xmlns:super="http://example.org/super" targetNamespace="http://example.org/sub" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:import namespace="http://example.org/super" schemaLocation="testSuper.xsd"/> <xs:element name="TestNode"> xs:complexType xs:sequence <xs:element name="category" type="SubObjectCategory" /> </xs:sequence> </xs:complexType> </xs:element> <xs:simpleType name="SubRequestType"> <xs:restriction base="xs:string"> <xs:enumeration value="REQUEST"/> <xs:enumeration value="RESPONSE"/> </xs:restriction> </xs:simpleType> <xs:complexType name="SubObjectCategory"> xs:complexContent <xs:restriction base="super:ObjectCategory"> xs:sequence <xs:element name="requestType" type="SubRequestType"/> </xs:sequence> </xs:restriction> </xs:complexContent> </xs:complexType> </xs:schema>

Best regards -dani

Environment

Operating System: All Platform: All

Affected Versions

[2.1.11]

Tomas-Kraus avatar Jul 06 '09 02:07 Tomas-Kraus

  • Issue Imported From: https://github.com/javaee/jaxb-v2/issues/662
  • Original Issue Raised By:@glassfishrobot
  • Original Issue Assigned To: @glassfishrobot

Tomas-Kraus avatar Sep 21 '18 15:09 Tomas-Kraus

@glassfishrobot Commented Reported by dkaeppeli

Tomas-Kraus avatar Jul 06 '09 02:07 Tomas-Kraus

@glassfishrobot Commented snajper said: Thanks for report, we'll try to look at it for 2.2.

Tomas-Kraus avatar Sep 11 '09 02:09 Tomas-Kraus

@glassfishrobot Commented snajper said: Adjusting priority of the issue.

Tomas-Kraus avatar Sep 11 '09 02:09 Tomas-Kraus

@glassfishrobot Commented snajper said: Reassigning to myself.

Tomas-Kraus avatar Sep 30 '09 07:09 Tomas-Kraus

@glassfishrobot Commented snajper said: Waiving for Metro 2.0, need to find TCK friendly solution.

Tomas-Kraus avatar Oct 23 '09 02:10 Tomas-Kraus

@glassfishrobot Commented snajper said: Adjusting priority based on waiver.

Tomas-Kraus avatar Oct 23 '09 02:10 Tomas-Kraus

@glassfishrobot Commented Was assigned to snajper

Tomas-Kraus avatar Jul 06 '09 02:07 Tomas-Kraus

@glassfishrobot Commented This issue was imported from java.net JIRA JAXB-662

Tomas-Kraus avatar Apr 24 '17 12:04 Tomas-Kraus