eclipse-ee4j / jaxb-ri

Jaxb RI
https://eclipse-ee4j.github.io/jaxb-ri/
BSD 3-Clause "New" or "Revised" License
204 stars 111 forks source link

Problems with jaxb:version #770

Open Tomas-Kraus opened 14 years ago

Tomas-Kraus commented 14 years ago

If I set jaxb:version="2.2" or jaxb:version="2.2.1" and run xjc, I get the following error message:

[ERROR] JAXB version attribute must be "1.0"

xjc will accept jaxb:version="2.1". I recommend that xjc be updated to accept "2.2" and "2.2.1". I also recommend that the error message be changed to:

[ERROR] Unrecognized JAXB version in jaxb:version attribute.

Environment

Operating System: Windows XP Platform: HP

Affected Versions

[2.2.1]

Tomas-Kraus commented 6 years ago
Tomas-Kraus commented 14 years ago

@glassfishrobot Commented Reported by lrflesch

Tomas-Kraus commented 14 years ago

@glassfishrobot Commented gmazza said: According to the binding schema's definition of the version attribute, the jaxb:version is not the version of JAXB (xjc) you're using, but rather the schema version of the binding file--here, for example, is 2.0's schema:

http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd

Replacing the 2 with a 1 above will get you the 1.0 schema.

Allowing values of 2.1, 2.2, 2.2.1, etc. will confuse things as it implies that you're specifying the desired version of xjc to use when in reality you're just stating the binding schema your binding file is following.

I think the switch should be then to allow just 1.0 or 2.0 as values (not 2.1, as there's no binding schema with that version number), and instead of "Unrecognized JAXB version..." as the error message (which could imply it can't read the binding file, and also might confuse users who are expecting to place the xjc version there) to say "JAXB binding schema version attribute must be "1.0" or "2.0".

Tomas-Kraus commented 14 years ago

@glassfishrobot Commented gmazza said: More info on this is in the JAXB 2.2 specification (Dec. 2009), Section 7.1.4:

7.1.4 Version Attribute The normative binding schema specifies a global version attribute. It is used to identify the version of the binding declarations. For example, a future version of this specification may use the version attribute to specify backward compatibility. To indicate this version of the specification, the version should be "2.0". It is also valid for @version to be “1.0�. If any other version is specified, it must result in an invalid customization as specified in Section 7.1.5, “Invalid Customizations.�

Tomas-Kraus commented 14 years ago

@glassfishrobot Commented gmazza said: Created an attachment (id=359) Patch to require 1.0 or 2.0 for binding schema version numbers

Tomas-Kraus commented 14 years ago

@glassfishrobot Commented gmazza said: Attached patch requires 1.0 or 2.0 for the binding schema value as required in Section 7.1.4 of the JAXB 2.2 spec. Acceptance of 2.1 has been removed.

However, unfortunately all episode files created by xjc--which are really binding files--have been using 2.1 as the binding schema version. The attached patch also fixes that problem and makes it use 2.0.

Unfortunately that will mean that those who use future versions of JAXB with their old episode files will need to lower the version number manually from 2.1 to 2.0. Expect some future hate mail as a result of this change, but per the spec, I don't see how JAXB/xjc can/should allow 2.1 as a value. Thankfully, changing the version number in an episode file is a pretty minor change to make.

Tomas-Kraus commented 14 years ago

@glassfishrobot Commented gmazza said: Marking as patch attached.

Tomas-Kraus commented 13 years ago

@glassfishrobot Commented snajper said: marking higher so that I look at this one

Tomas-Kraus commented 14 years ago

@glassfishrobot Commented File: 20100702_Bug770.diff Attached By: gmazza

Tomas-Kraus commented 14 years ago

@glassfishrobot Commented Was assigned to snajper

Tomas-Kraus commented 7 years ago

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