Git Product home page Git Product logo

jaxb-ri's Introduction

Eclipse Implementation of JAXB

Build Status Jakarta Staging (Snapshots)

Jakarta XML Binding gives Java developers an efficient and standard way of mapping between XML and Java code. Java developers using Jakarta XML Binding are more productive because they can write less code themselves and do not have to be experts in XML. Jakarta XML Binding makes it easier for developers to extend their applications with XML and Web Services technologies.

Eclipse Implementation of JAXB enables developers to perform the following operations:

  • Unmarshal XML content into a Java representation
  • Access and update the Java representation
  • Marshal the Java representation of the XML content into XML content

This project is part of Eclipse Implementation of JAXB

License

Eclipse Implementation of JAXB is licensed under a license - EDL 1.0.

Contributing

We use contribution policy, which means we can only accept contributions under the terms of Eclipse Contributor Agreement.

Links

Other projects in this repository:

jaxb-ri/codemodel

Codemodel is an independent library for java code generation, which can be released separately. Besides here it is used in istack-commons-project, which in turn is a dependency of JAXB

jaxb-ri/xsom

XML Schema Object Model (XSOM) is a Java library that allows applications to easily parse XML Schema documents and inspect information in them. It can be released separately to satisfy a dependency of jaxb-fi, which in turn is optional dependency of JAXB

jaxb-ri/external

RNGOM and relaxng-datatype under jaxb-ri/external are tools for working with RelaxNG. Both can be released separately to break circular dependency between several jaxb-ri sub-projects including jaxb-ri/xsom above.

jaxb-ri's People

Contributors

bjornvester avatar bravehorsie avatar danielkec avatar dependabot[bot] avatar eclipse-jaxb-impl-bot avatar exe-boss avatar gaol avatar gorky avatar jakobbraun avatar jbescos avatar jimma avatar knfujimoto avatar laurentschoelens avatar lukasj avatar marschall avatar mtheiss avatar nros avatar ohumbel avatar oritmarkus avatar patrodyne avatar pieterjanpintens avatar pzygielo avatar rcosne avatar sanddusttx avatar scottmarlow avatar stbischof avatar stephan202 avatar tomas-kraus avatar tvallin avatar whitingjr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jaxb-ri's Issues

Supporting Appendix E.2

The JAXB 1.0 specification defines in Appendix E.2 "Not Required XML Schema
concepts". Please could these be supported.

JAXB's current behaviour varies from gracefully exiting after reporting the
unsupported feature to bypassing or ignoring the feature.

Please could some attempt be made to support Substitution and Redefine in
particular.

I appreciate the difficulties of handling wildcard types.

Environment

Operating System: All
Platform: All

Affected Versions

[JWSDP1.3 (JAXB1.0.2)]

stack overflow bug when maxoccurs is big (eg. 1000) and not unbounded

Below is a example dtd that I passed into xjc followed by the error . It does
not matter whether the element in the sequence is a link or not. When the
attribute maxOccurs is a big number eg. 1000. Tried to increase stack size and
also heap size, still the same error. However, there is no bug when
maxoccurs="unbounded"


<xs:schema elementFormDefault = "qualified" xmlns:xs
= "http://www.w3.org/2001/XMLSchema">
<xs:element name = "RootElement">
xs:complexType
xs:sequence
<xs:element name = "Details" minOccurs = "0" maxOccurs = "1000">
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>


Error Generated

Stack overflow. Either you are compiling a large schema that requires more
resource, or XJC has a bug. First, please extend the stack size by using the -
Xss JVM option. If this doesn't solve the problem, please use the -debug
option to obtain the stack trace and contact Sun.

Environment

Operating System: Windows XP
Platform: PC

Affected Versions

[JWSDP1.3 (JAXB1.0.2)]

StackOverflowError when compiling with xjc

Using JWSDP1.5, but I didn't see it in the version list, so I just put 1.4.

I'm getting a StackOverflowError when compiling one of my schemas with the xjc
ant task. I've tried setting the stacksize attribute to various settings, even
as high as 1000mb and still get it. The schema is pretty large, but I would
think that a stacksize of 1000mb is sufficient.

The main schema is called PoweredPNR_PNRReply.xsd, and it imports another schema
called PoweredPNR_Common.xsd. The URLs for the schemas are listed below.

http://affiliate.ihsadvantage.com/tomcat-docs/PoweredPNR_Common.xsd
http://affiliate.ihsadvantage.com/tomcat-docs/PoweredPNR_PNRReply.xsd

Environment

Operating System: Windows XP
Platform: PC

Affected Versions

[JWSDP1.5 (JAXB1.0.4)]

test. please ignore.

Testing ...

Environment

Operating System: All
Platform: All

Affected Versions

[JWSDP1.1 (JAXB1.0)]

Generated runtime is not always the same.

Version jaxb-ri-20031215.

We generate many source from XML schemas. We also generate from a "dummy" XML
schema in order to generate a common runtime that we re-use when we generate all
of the other schema. In the new schema I am working with I use the Sun
customization "xjc:dom". The new schema caused compilation problems with a type
not found. (can't recall since I hacked this in my "dummy" schema a couple of
days ago).

After I added the same xjc:dom customization to the dummy schema used to
generate the common runtime, the new schema (and all others of course) compiled
fine.

The bug IMO, is that the generated schema should always be the same, and include
everything I could beed, such that I can actaully reuse it.

Of course, this begs the question of what is the point of a common runtime since
the generated code is dependent of the JAXB libraries no matter what.

I would also suggest that one should be able to use the Ant xjc task to generate
the runtime without having to specify a dummy schema.

Environment

Operating System: Windows XP
Platform: PC

Affected Versions

[JWSDP1.6 (JAXB1.0.5)]

Generated time in the header of java files created by xjc does not indicate afternoon times

After running xjc, the generated Java files contain a header which gives the
time the file was generated, eg:

// Generated on: 2005.05.06 at 03:29:49 BST

This looks like it was generated at 3:29, however it was generated at 15:29
(I'm guessing it shoudl use the 24 hour clock as there is no am/pm there).
When files are generated in the morning the time is correct.

Not important, but I thought I'd mention it.

Steve

Environment

Operating System: All
Platform: All

Affected Versions

[2.0 EA1]

testing

another test.

Environment

Operating System: All
Platform: All

Affected Versions

[JWSDP1.1 (JAXB1.0)]

XJC doesn't work with directories with spaces in them

If you use the full path name of a bindings file, and it has a
space in it, then XJC won't work, even if you surround the filename in
quotes.
Example with space in directory:
C:\Data\etp>xjc -b c:\data\etp\JAXB Bindings\JAXBBinding3.xjb -d C:\WSAD-IE5-WS
Workspace-ETP01\JAXB\GeneratedClasses -p uk.org.ppa.etp.jaxb -use-runtime uk.or
g.ppa.etp.jaxb.impl.runtime -nv C:\WSAD-IE5-WS\Workspace-ETP01\JAXB\Schemas\PORX
_IN150101UK01.xsd
parsing a schema...
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.commons.launcher.ChildMain.run(ChildMain.java:269)
Caused by: java.io.FileNotFoundException: C:\Data\etp\Bindings\JAXBBinding3.xjb
(The system cannot find the path specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.(FileInputStream.java:106)
at java.io.FileInputStream.(FileInputStream.java:66)
at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection
.java:69)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLCon
nection.java:156)
at java.net.URL.openStream(URL.java:913)
at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(XMLEntityM
anager.java:947)
at org.apache.xerces.impl.XMLEntityManager.startEntity(XMLEntityManager.
java:893)
at org.apache.xerces.impl.XMLEntityManager.startDocumentEntity(XMLEntity
Manager.java:846)
at org.apache.xerces.impl.XMLDocumentScannerImpl.setInputSource(XMLDocum
entScannerImpl.java:264)
at org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.jav
a:513)
at org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.jav
a:595)
at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152)
at org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.j
ava:1125)
at org.xml.sax.helpers.XMLFilterImpl.parse(Unknown Source)
at org.xml.sax.helpers.XMLFilterImpl.parse(Unknown Source)
at com.sun.tools.xjc.reader.internalizer.DOMForest.parse(DOMForest.java:
171)
at com.sun.tools.xjc.reader.internalizer.DOMForest.parse(DOMForest.java:
124)
at com.sun.tools.xjc.GrammarLoader.buildDOMForest(GrammarLoader.java:313
)
at com.sun.tools.xjc.GrammarLoader.loadXMLSchema(GrammarLoader.java:372)

at com.sun.tools.xjc.GrammarLoader.load(GrammarLoader.java:130)
at com.sun.tools.xjc.GrammarLoader.load(GrammarLoader.java:79)
at com.sun.tools.xjc.Driver.run(Driver.java:177)
at com.sun.tools.xjc.Driver._main(Driver.java:80)
at com.sun.tools.xjc.Driver.access$000(Driver.java:46)
at com.sun.tools.xjc.Driver$1.run(Driver.java:60)

Example with directory name in quotes:
C:\Data\etp>xjc -b "c:\data\etp\JAXB Bindings\JAXBBinding3.xjb" -d C:\WSAD-IE5-W
S\Workspace-ETP01\JAXB\GeneratedClasses -p uk.org.ppa.etp.jaxb -use-runtime uk.
org.ppa.etp.jaxb.impl.runtime -nv C:\WSAD-IE5-WS\Workspace-ETP01\JAXB\Schemas\PO
RX_IN150101UK01.xsd
Bindings\JAXBBinding3.xjb"x"=="x" was unexpected at this time.

Environment

Operating System: Windows XP
Platform: All

Affected Versions

[JWSDP1.3 (JAXB1.0.2)]

Error in generated source code, type cast needed

Part of generated source code from XML Schema in imlp package with comments
of the bug
...
protected java.io.Serializable _Appearance;
...
public void serializeURIs(test2.impl.runtime.XMLSerializer context)
throws org.xml.sax.SAXException
{
int idx7 = 0;
final int len7 = _ListUICommon.size();
int idx9 = 0;
final int len9 = _UICommon.size();
if (_Appearance!= null) {
if (_Appearance instanceof javax.xml.namespace.QName) {
try

{ //**************** //field _Appearance is declared as java.io.Serializable. //Probably there is need in type casting _Appearance to javax.xml.namespace.QName context.getNamespaceContext().declareNamespace (_Appearance.getNamespaceURI(), _Appearance.getPrefix(), false); //**************** }

catch (java.lang.Exception e)

{ test2.impl.runtime.Util.handlePrintConversionException(this, e, context); }

}
}
if (_Label instanceof javax.xml.bind.Element)

{ context.childAsURIs(((com.sun.xml.bind.JAXBObject) _Label), "Label"); }

while (idx7 != len7)

{ context.childAsURIs(((com.sun.xml.bind.JAXBObject) _ListUICommon.get (idx7 ++)), "ListUICommon"); }

while (idx9 != len9) {
while (idx9 != len9)

{ context.childAsURIs(((com.sun.xml.bind.JAXBObject) _UICommon.get (idx9 ++)), "UICommon"); }

}
}

2. parts of XML Schema
_Appearence from the source comes from definition of element "select1" which has
attributeGroup "UI.Common.Attrs" which has attribute "appearance"
...
<xsd:simpleType name="QNameButNotNCNAME">
<xsd:restriction base="xsd:QName">
<xsd:pattern value="[^:]:[^:]"/>
</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="appearanceType">
<xsd:union memberTypes="xforms:QNameButNotNCNAME">
xsd:simpleType
<xsd:restriction base="xsd:string">
<xsd:enumeration value="full"/>
<xsd:enumeration
value="compact"/>
<xsd:enumeration
value="minimal"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:union>
</xsd:simpleType>
...
<xsd:element name="select1">
xsd:complexType
xsd:sequence
<xsd:element ref="xforms:label"/>
<xsd:group ref="xforms:List.UI.Common"
maxOccurs="unbounded"/>
<xsd:group ref="xforms:UI.Common"
minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attributeGroup ref="xforms:Common.Attributes"/>
<xsd:attributeGroup
ref="xforms:Single.Node.Binding.Attributes"/>
<xsd:attributeGroup ref="xforms:UI.Common.Attrs"/>
<xsd:attribute name="selection" use="optional"
default="closed">
xsd:simpleType
<xsd:restriction base="xsd:string">
<xsd:enumeration
value="open"/>
<xsd:enumeration
value="closed"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="incremental"
type="xsd:boolean" use="optional" default="true"/>
</xsd:complexType>
</xsd:element>
...
<xsd:attributeGroup name="UI.Common.Attrs">
<xsd:attribute name="appearance"
type="xforms:appearanceType" use="optional"/>
</xsd:attributeGroup>
...

Environment

Operating System: Windows XP
Platform: PC

Affected Versions

[JWSDP1.3 (JAXB1.0.2)]

Javadoc warning on compiled ObjectFactory class

A warning is generated out of the javadoc for the compiled ObjectFactory class.

public class ObjectFactory
extends com.fedex.ctrac.xml.impl.runtime.DefaultJAXBContextImpl

{ private static java.util.HashMap defaultImplementations = new java.util.HashMap(16, 0.75F); private static java.util.HashMap rootTagMap = new java.util.HashMap(); public final static com.fedex.ctrac.xml.impl.runtime.GrammarInfo grammarInfo = new com.fedex.ctrac.xml.impl.runtime.GrammarInfoImpl(rootTagMap, defaultImplementations, (com.fedex.ctrac.xml.ObjectFactory.class)); public final static java.lang.Class version = (com.fedex.ctrac.xml.impl.JAXBVersion.class); ... }

GrammarInfo is from the *.impl package and is not being generated as part of
the javadoc.

javadoc:
[javadoc] Generating Javadoc
[javadoc] Javadoc execution
[javadoc] Loading source
file /home/supplies/xml/build/com/fedex/ctrac/xml/CollectionType.java...
[javadoc] Loading source
file /home/supplies/xml/build/com/fedex/ctrac/xml/CommRequest.java...
[javadoc] Loading source
file /home/supplies/xml/build/com/fedex/ctrac/xml/CommRequestType.java...
[javadoc] Loading source
file /home/supplies/xml/build/com/fedex/ctrac/xml/IntType.java...
[javadoc] Loading source
file /home/supplies/xml/build/com/fedex/ctrac/xml/ObjectFactory.java...
[javadoc] Loading source
file /home/supplies/xml/build/com/fedex/ctrac/xml/RpsSupplyOrderType.java...
[javadoc] Loading source
file /home/supplies/xml/build/com/fedex/ctrac/xml/StringType.java...
[javadoc] Constructing Javadoc information...
[javadoc] javadoc: warning - Cannot find class
com.fedex.ctrac.xml.impl.runtime.GrammarInfo
[javadoc] Building tree for all the packages and classes...
[javadoc] Building index for all the packages and classes...
[javadoc] Building index for all classes...
[javadoc] Generating /home/supplies/xml/docs/api/stylesheet.css...
[javadoc] 1 warning

Environment

Operating System: All
Platform: All

Affected Versions

[JWSDP1.4 (JAXB1.0.3)]

Defect in DTD binding information file (bindingfile.nrg)

There is a problem with the spec file for DTD binding schema. I've included the
part from JWSDP1.5 that I'm using. The problem is with the "attribute"
specification for "element".

sequence choice As you can see, the spec file (com/sun/tools/xjc/reader/dtd/binding/bindingfile.nrg) specifies that "attribute" is a sub-element of "content" tag. But this is not correct. Attribute is sub-element of "element" tag and not content tag. A binding schema written to this specification will fail with the following error:

parsing a schema...
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.commons.launcher.ChildMain.run(ChildMain.java:269)
Caused by: com.sun.xml.bind.JAXBAssertionError
at com.sun.tools.xjc.reader.dtd.bindinfo.BIContent.create
(BIContent.java:185)
at com.sun.tools.xjc.reader.dtd.bindinfo.BIElement.
(BIElement.java:48)
at com.sun.tools.xjc.reader.dtd.bindinfo.BindInfo.
(BindInfo.java:77)
at com.sun.tools.xjc.reader.dtd.bindinfo.BindInfo.
(BindInfo.java:58)
at com.sun.tools.xjc.reader.dtd.TDTDReader.(TDTDReader.java:117)
at com.sun.tools.xjc.reader.dtd.TDTDReader.parse(TDTDReader.java:85)
at com.sun.tools.xjc.GrammarLoader.loadDTD(GrammarLoader.java:260)
at com.sun.tools.xjc.GrammarLoader.load(GrammarLoader.java:113)
at com.sun.tools.xjc.GrammarLoader.load(GrammarLoader.java:76)
at com.sun.tools.xjc.Driver.run(Driver.java:181)
at com.sun.tools.xjc.Driver._main(Driver.java:80)
at com.sun.tools.xjc.Driver.access$000(Driver.java:46)
at com.sun.tools.xjc.Driver$1.run(Driver.java:60)
This is because the BIConent.create method will not accept "attribute" tag
inside content tag:

static BIContent create(Element e, BIElement _parent) {
String tagName = e.getName();
if (tagName.equals("element-ref"))
return new BIContent(e, _parent) {
protected boolean checkMatch(Expression exp)

{ return (Object) exp instanceof ReferenceExp; }

};
if (tagName.equals("choice"))
return new BIContent(e, _parent) {
protected boolean checkMatch(Expression exp)

{ return (Object) exp instanceof ChoiceExp; }

};
if (tagName.equals("sequence"))
return new BIContent(e, _parent) {
protected boolean checkMatch(Expression exp)

{ return (Object) exp instanceof SequenceExp; }

};
if (tagName.equals("rest") || tagName.equals("content"))
return new BIContent(e, _parent) {
protected boolean checkMatch(Expression exp)

{ throw new JAXBAssertionError(); }

};
throw new JAXBAssertionError();
}

Environment

Operating System: All
Platform: All

Affected Versions

[JWSDP1.5 (JAXB1.0.4)]

validation false negative when using xerces as XMLReader?

hi,

please find attached a zip file containing:

  1. /build.xml
  2. /product.xml
  3. /src/xsd/warehouse-2_0.xsd
  4. /src/xsd/warehouse-04.dtd
  5. /src/JAXBTest.java
  6. /142.txt
  7. /150RC.txt

where

  1. is an ANT build file that builds and runs the test
  2. product.xml is an xml instance file that is showing the problem up
  3. xsd is the schema compiled with xjc
  4. dtd is the dtd referenced from the xml instance (although the URL in the
    DOCTYPE should be accessible also)
  5. is the java code that shows the symptom
  6. 142.txt is a log of running under Suns 142_05 jre
  7. 150RC.txt is a log of running under the tiger RC1 build

It is hopefully a matter of just unzipping the zip and typing

ant -Djwsdp_dir=C:\work\jwsdp-1.4

where the java property jwsdp_dir is the directory containing the web services
developer pack

Items 6 & 7 above give the output and stack traces


The stack trace from (6) is:

[java] DefaultValidationEventHandler: [FATAL_ERROR]: Unexpected end of
element {}:VAR
[java] javax.xml.bind.UnmarshalException: Unexpected end of element {}:VAR
[java] Location:
[java] at
com.arm.dragonfly.wh.jaxb.wxml.impl.runtime.SAXUnmarshallerHandlerImpl.handleEve
nt(SAXUnmarshallerHandlerImpl.java:568)
[java] at
com.arm.dragonfly.wh.jaxb.wxml.impl.runtime.AbstractUnmarshallingEventHandlerImp
l.reportError(AbstractUnmarshallingEventHandlerImpl.java:140)
[java] at
com.arm.dragonfly.wh.jaxb.wxml.impl.runtime.AbstractUnmarshallingEventHandlerImp
l.reportError(AbstractUnmarshallingEventHandlerImpl.java:137)
[java] at
com.arm.dragonfly.wh.jaxb.wxml.impl.runtime.AbstractUnmarshallingEventHandlerImp
l.unexpectedLeaveElement(AbstractUnmarshallingEventHandlerImpl.java:154)
[java] at
com.arm.dragonfly.wh.jaxb.wxml.impl.runtime.AbstractUnmarshallingEventHandlerImp
l.leaveElement(AbstractUnmarshallingEventHandlerImpl.java:64)
[java] at
com.arm.dragonfly.wh.jaxb.wxml.impl.VARIETYImpl$Unmarshaller.leaveElement
(VARIETYImpl.java:439)
[java] at
com.arm.dragonfly.wh.jaxb.wxml.impl.runtime.SAXUnmarshallerHandlerImpl.endElemen
t(SAXUnmarshallerHandlerImpl.java:140)
[java] at org.iso_relax.verifier.impl.ForkContentHandler.endElement
(ForkContentHandler.java:81)
[java] at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement
(AbstractSAXParser.java:585)
[java] at
com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElemen
t(AbstractXMLDocumentParser.java:221)
[java] at
com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.emptyElement
(XMLDTDValidator.java:820)
[java] at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStart
Element(XMLDocumentFragmentScannerImpl.java:839)
[java] at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentC
ontentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1563)
[java] at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocum
ent(XMLDocumentFragmentScannerImpl.java:341)
[java] at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse
(XML11Configuration.java:828)
[java] at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse
(XML11Configuration.java:758)
[java] at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse
(XMLParser.java:148)
[java] at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse
(AbstractSAXParser.java:1178)
[java] at
com.arm.dragonfly.wh.jaxb.wxml.impl.runtime.UnmarshallerImpl.unmarshal
(UnmarshallerImpl.java:140)
[java] at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal
(AbstractUnmarshallerImpl.java:114)
[java] at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal
(AbstractUnmarshallerImpl.java:97)
[java] at JAXBTest.main(JAXBTest.java:57)

where the validation error states that VAR has ended unexpectedly:

"Unexpected end of element {}:VAR"

but I can verify that

a) the xsd passed to xjc declares VAR to be empty:
<xsd:complexType name="VAR">
<xsd:attribute name="n" type="xsd:string"
use="required"/>
<xsd:attribute name="v" type="xsd:string"
use="required"/>
</xsd:complexType>
b) the dtd that the xml instance document declares via a DOCTYPE also
declares VAR to be empty:

c) the XML instance document correctly uses VAR:


I've made sure that the file being parsed really is the one that is being
complained about, and have recompiled my application from scratch - this feels
like I've missed something trivial but I've now run out of things to check..

The XmlReader and SaxParser are instances of classes:
com.sun.org.apache.xerces.internal.parsers.SAXParser
com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl

(running under a build of jre1.5)

I've believe i've tried (ie i got confused with the permutations of options at
one point..)
a) not having the unmarshalling perform any validation
b) not having the SAX parser perform any validation and it doesn't seem
to have any effect - if the document is parsed via sax then the
unmarshaller.unmarshal(...) call always reports a FATAL error to the validation
handler (which in then hrows a runtime exception)

please don't hesitate to contact me for any missing details/clarifications

(One thing that has confused me is that I though 1.4.2 used crimson as its
parser, so am not sure where xerces is being picked up when running under that)

thanks,
Andrew
[email protected]

Environment

Operating System: All
Platform: All

Affected Versions

[JWSDP1.4 (JAXB1.0.3)]

Unable to xjc XMLSchema.xsd

In order to provide programmatic access to creating XSDs for use with JAXB, I
tried to compile XMLSchema.xsd (from w3c) with JAXB โ€“ thus providing OO access.

It fails to compile with many errors. Tried removing the DTD portion from the
top, but it still failed. My guess is that the XMLSchema.xsd somehow does not
follow its own rules, but...

Environment

Operating System: All
Platform: All

Affected Versions

[JWSDP1.3 (JAXB1.0.2)]

DTD downloaded even if not used.

The XML I have has an old DTD declaration which I want to ignore. I have the
following code which turns off DTD validation. This code won't run unless
there's an internet connection as the DTD is downloaded.

I even tried to use *.setValidating(false) and turn off validation altogether.
Still the DTD seems to be downloaded.

I think the "features" are being ignored by JAXB. Is this a good assumption?

Unmarshaller u = getUnmarshaller();
ByteArrayInputStream is = new ByteArrayInputStream(xml);

u.setValidating(false);

SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
spf.setValidating(true);
spf.setFeature("http://apache.org/xml/features/nonvalidating/load-
external-dtd", false);
spf.setFeature("http://apache.org/xml/features/validation/schema",
true);

SAXParser saxParser = spf.newSAXParser();

saxParser.setProperty
("http://java.sun.com/xml/jaxp/properties/schemaLanguage"
, "http://www.w3.org/2001/XMLSchema");
saxParser.setProperty
("http://java.sun.com/xml/jaxp/properties/schemaSource",
this.getClass().getClassLoader().getResourceAsStream
("nokiarss.xsd"));

XMLReader reader = saxParser.getXMLReader();
SAXSource source = new SAXSource(reader, new InputSource(is));

return (RDF)u.unmarshal(source);

Thanks,
Emmanuel

Environment

Operating System: All
Platform: All

Affected Versions

[JWSDP1.3 (JAXB1.0.2)]

XmlID not being found

I am getting an incorrect error that an object does not have an ID when it does
in fact have an ID.

Code:

package jaxbtest2;

import javax.xml.bind.annotation.*;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
import javax.xml.bind.JAXBException;

@XmlRootElement
class Root extends A {

public static void main(String[] args) throws JAXBException

{ JAXBContext jaxbContext = JAXBContext.newInstance(Root.class); Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty("jaxb.formatted.output", Boolean.TRUE); Root root = new Root(); C c = new C(); root.b = new B("b"); root.c = c; c.b = root.b; marshaller.marshal(root, System.out); }

}

class A {
@xmlid
@XmlAttribute(name="Name") String name = "myName";

@xmlelement B b;
@xmlelement C c;

public A() {
}

public A(String name)

{ this.name = name; }

}

class B extends A {
public B() {
}

public B(String name)

{ super(name); }

}

class C {
@XmlIDREF
@XmlAttribute A b;
}

DefaultValidationEventHandler: [ERROR]: Object "jaxbtest2.B@39443f" is found in
an IDREF property but this object doesnt have an ID.
Location: obj: jaxbtest2.B@39443f
Exception in thread "main" javax.xml.bind.MarshalException

  • with linked exception:
    [com.sun.xml.bind.serializer.AbortSerializationException: Object
    "jaxbtest2.B@39443f" is found in an IDREF property but this object doesnt have
    an ID.]
    at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:230)
    at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:162)
    at
    javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:68)
    at jaxbtest2.Root.main(A.java:20)

It may be interesting to note that if the type of A.b is changed from B to A,
the code works correctly.

Environment

Operating System: All
Platform: All

Affected Versions

[2.0 EA1]

JAXB: Exception thrown during Unmarshalling ! HELP !

Hi,
My JAXB works fine when the input XML conforms with the schema. But sometimes
the input XML contains some extra non-business related fields (populated by the
client application) that are absent from my schema definitions and cannot be
predicted. In such scenarios JAXB fails during unmarshalling. Is there a way
round this ? I have tried Unmarshaller.setValidating( false), but still fails !
Ideally I would want the parser to ignore such fields. Do I need to write a
custom EventHandler as means of a way out? Kindly suggest

Thanks.

Environment

Operating System: Windows 2000
Platform: All

Affected Versions

[JWSDP1.5 (JAXB1.0.4)]

xjc.bat - DOS variables need double quotes

The xjc.bat file needs correcting.

By default the JDK 1.5 installs into the "/Program Files/jdk..." directory,
because there is a space in this PATH, the JAVA_HOME DOS in the xjc.bat file
should be surrounded by quotes, otherwise it when you run it from the DOS prompt
it says.

The name specified is not recognized as an
internal or external command, operable program or batch file.

The code in the bat file should be changed to ...

set JAVA="%JAVA_HOME%\bin\java"

Environment

Operating System: Windows NT
Platform: Other

Affected Versions

[2.0 EA1]

Performance Improvement in NamespaceContextImpl.java

Currently when JAXB generates the method endNamespaceDecls(), the method creates
an iterator even if the decls collection is empty. The current implementation is
as shown below:

public void endNamespaceDecls() {
for( Iterator itr=decls.entrySet().iterator(); itr.hasNext(); )

{ Map.Entry e = (Map.Entry)itr.next(); String prefix = (String)e.getKey(); String uri = (String)e.getValue(); if(!uri.equals(nss.getURI(prefix))) // avoid redundant decls. nss.declarePrefix( prefix, uri ); }

decls.clear();
reverseDecls.clear();
inCollectingMode = false;

There is substantial performance improvement if the same method is generated as
shown below!
public void endNamespaceDecls() {
if (!decls.isEmpty()){
for( Iterator itr=decls.entrySet().iterator(); itr.hasNext(); )

{ Map.Entry e = (Map.Entry)itr.next(); String prefix = (String)e.getKey(); String uri = (String)e.getValue(); if(!uri.equals(nss.getURI(prefix))) // avoid redundant decls. nss.declarePrefix( prefix, uri ); }

}
decls.clear();
reverseDecls.clear();
inCollectingMode = false;
}

Environment

Operating System: Windows 2000
Platform: PC

Affected Versions

[JWSDP1.3 (JAXB1.0.2)]

With the same inputs, XJC does not repeatably generate the same code

If you run XJC on the same input schemas multiple times, certain generated code
fragments will not be binary equal, although they are semantically equal.

The root of the issue is that HashMaps are used throughout to store the
structures. However, since HashMaps don't guarantee any ordering, the keys are
returned arbitrarily when the code is generated.

An easy way to get repeatable output is to replace usages of HashMap with usages
of LinkedHashMap in the XJC code (LinkedHashMap returns keys in the order they
were inserted).

The reason this is an issue for me is that our build process does XJC as a two
step process. First it generates the JAXB code into a temporary build
directory. Then it copies any changed files from the build directory to the
revisioned source tree. The build directory is obviously removed when doing a
"clean".

I've downloaded the XJC source and done the HashMap -> LinkedHashMap replacement
and have gotten the desired results. I'm not sure which specific Maps were the
culprits, so I simply replaced them all.

Environment

Operating System: All
Platform: All

Affected Versions

[JWSDP1.6 (JAXB1.0.5)]

Createing JAXBContext for large schemas takes a long time

Creating a JAXBContext instance for genereated classes for extremely large
schemas takes a very long time. I think this is because the generated
ObjectFactory has (again) references to .class files in it's static initialization
block. Having these references causes all the classes referenced to be loaded by
the JVM when the ObjectFactory is loaded.

This issue was fixed in the prior version (1.0.1) but re-appeared in 1.0.2.

Environment

Operating System: All
Platform: All

Affected Versions

[JWSDP1.3 (JAXB1.0.2)]

Bug with separate compilation of XSDs that reference a common XSD with inheritance

I have two schemas A and B each in their own namespace that both
extend a third schema C also in its own name space.

I run the jaxb ant task on each schema A and B separately. In each
case the local classes are generated for elements in schema A and B
as well as all the classes for elements defined in the common schema C.
I would expect the two copies of the C schema defined jaxb classes to
be the same and also identical to the classes generated from schema C
on its own. This is not the case.

When compiling the schemas all at once there is no problem.

Environment

Operating System: Windows 2000
Platform: PC
URL: https://jaxb.dev.java.net/servlets/ReadMsg?list=users&msgId=49271

Affected Versions

[JWSDP1.3 (JAXB1.0.2)]

Failure On Unmarshall choice element unbounded

There is a problem with schema elements containing an unbounded choice similar
to the following:
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="property"
type="propertyType"/>
<xs:element name="many-to-one"
type="many-to-oneType"/>
<xs:element name="one-to-one" type="one-
to-oneType"/>
<xs:element name="component"
type="componentType"/>
<xs:element name="dynabean"
type="dynabeanType"/>
<xs:element name="map"
type="mapType"/>
<xs:element name="set" type="setType"/>
<xs:element name="list" type="listType"/>
<xs:element name="bag" type="bagType"/>
<xs:element name="array"
type="arrayType"/>
<xs:element name="primitive-array"
type="primitive-arrayType"/>
</xs:choice>

The list property accepts values from any of the choice types as expected but
upon Unmarshalling the object elements are not created. Any attributes
associated with the objects that are resident in the list are added to the
parent element.

For example if the above is a child of a complex type called ClassType
resulting in an object: ClassType and ClassTypeImpl with a list accesible through
getPropertyOrOneToManyOrOneToOne().add(PropertyType)

then the attributes found in each PropertyType added to the collection will be
found as attributes of the ClassType when unmarshalling occurs.

Environment

Operating System: Windows XP
Platform: PC

Affected Versions

[JWSDP1.3 (JAXB1.0.2)]

Generated runtime depends on XJC jar.

I am trying to migrate to JAXB version 1.0.3 included in JWSPD 1.4.

I've generated code that contains:

UnmarshallerHandler handler = new InterningUnmarshallerHandler( createUnmarshallerHandler(new DOMLocator(scanner)));

This code is generated in my JAXB shared runtime, which for us is in
com.seagullsw.toolbox.xml.jaxb.impl.runtime

Our build's JAXB code gen works fine but the compilation no longer works. The
following class is undefined: InterningUnmarshallerHandler. After some digging I
found InterningUnmarshallerHandler packaged in jwsdp 1.4
./jaxb/lib/jaxb-xjc.jar. We've never included jaxb-xjc.jar on our compile path
before.

This seems like a bug. Generated code should not rely on the compiler jar.
Should it? If this is normal, it means we must deliver jaxb-xjc.jar with our
runtime, which does not feel right.

Please advise.

Thank you,
Gary

Environment

Operating System: All
Platform: All

Affected Versions

[JWSDP1.4 (JAXB1.0.3)]

Default values based on schema

JAXB 1.0 spec 4.5.4 "isSet Property Modifier" talks about returning schema-specific
defaults by a getter in case of initialization and unsetting on an instance.
However, JAXB 1.0.2 implementation doesn't provide this feature.

For your information, JaxMe from Apache (http://ws.apache.org/jaxme/) support
that. (See DefaultValueTest for more details.)

Environment

Operating System: All
Platform: All

Affected Versions

[JWSDP1.3 (JAXB1.0.2)]

xs:any namespace="##any" processContents="skip" not returning data

Weekly build 20031215.
I am trying to specify that an element can contain anything with (see request.xsd):

<xs:element name="Request">
xs:complexType
xs:sequence
<xs:element name="Input">
xs:complexType
xs:sequence
<xs:any namespace="##any"
processContents="skip"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attributeGroup ref="req:requestAttributeGroup"/>
</xs:complexType>
</xs:element>

The reason for this is that we have some legacy XML that we need to integrate in
a containing document. That legacy XML can be pretty much anything and has its
own pile of non-Jaxb code to handle it.

I want to use Jaxb for the containing document and then pass on the string or
DOM Node or /whatever/ down to our other code pile.

This Schema snippet allows my example document to be validated in XMLSpy as well
as parsed by the generated Jaxb code but the "contents" are
null in the attached Java example.

Is it possible to get Jaxb to give me /something/ for the contents of ?

Thank you,
Gary

Environment

Operating System: Windows XP
Platform: PC

Affected Versions

[JWSDP1.6 (JAXB1.0.5)]

NullPointerException when user class used as an attribute

The code below generates a NullPointerException. It should generate a more
helpfull error message, perhaps indicating that the given class cannot be used
as an attribute.

Code:
package jaxbtest;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class A {
@XmlAttribute public B b = new B();
public static void main(String[] args) throws JAXBException

{ JAXBContext jaxbContext = JAXBContext.newInstance(A.class); Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.marshal(new A(), System.out); }

}

class B {
}

Exception:
Exception in thread "main" java.lang.NullPointerException
at
com.sun.xml.bind.v2.runtime.reflect.TransducedAccessor.get(TransducedAccessor.java:103)
at
com.sun.xml.bind.v2.model.impl.RuntimeAttributePropertyInfoImpl.calcTransducedAccessor(RuntimeAttributePropertyInfoImpl.java:74)
at
com.sun.xml.bind.v2.model.impl.RuntimeAttributePropertyInfoImpl.getTransducedAccessor(RuntimeAttributePropertyInfoImpl.java:61)
at
com.sun.xml.bind.v2.model.impl.RuntimeAttributePropertyInfoImpl.link(RuntimeAttributePropertyInfoImpl.java:86)
at com.sun.xml.bind.v2.model.impl.ClassInfoImpl.link(ClassInfoImpl.java:654)
at
com.sun.xml.bind.v2.model.impl.RuntimeClassInfoImpl.link(RuntimeClassInfoImpl.java:75)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.link(ModelBuilder.java:208)
at
com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.link(RuntimeModelBuilder.java:67)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:88)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:210)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:356)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:546)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:493)
at jaxbtest.A.main(A.java:13)

Environment

Operating System: All
Platform: All

Affected Versions

[2.0 EA1]

wrong encoding xml

Hi!

When jaxb marshall, it change string:
Before marshalling:
valueOfTag1valueOfTag2

After marshalling:

valueOfTag1valueOfTag2</tag
2>

And the integrity of XML is changed !!!

Environment

Operating System: All
Platform: All

Affected Versions

[JWSDP1.2 (JAXB1.0.1)]

StackOverflowErrors

Hi.

I'm getting a StackOverflowError on certain schemas.

Seems like an infinite recursion:

...
at com.sun.msv.grammar.util.ExpressionWalker.onBinExp(ExpressionWalker.java:73)
at com.sun.msv.grammar.util.ExpressionWalker.onChoice(ExpressionWalker.java:65)
at com.sun.msv.grammar.ChoiceExp.visit(ChoiceExp.java:26)
at com.sun.msv.grammar.util.ExpressionWalker.onBinExp(ExpressionWalker.java:74)
at com.sun.msv.grammar.util.ExpressionWalker.onSequence(ExpressionWalker.java:69)
at com.sun.msv.grammar.SequenceExp.visit(SequenceExp.java:24)
at com.sun.msv.grammar.util.ExpressionWalker.onBinExp(ExpressionWalker.java:73)
at com.sun.msv.grammar.util.ExpressionWalker.onChoice(ExpressionWalker.java:65)
at com.sun.msv.grammar.ChoiceExp.visit(ChoiceExp.java:26)
at com.sun.msv.grammar.util.ExpressionWalker.onBinExp(ExpressionWalker.java:74)
at com.sun.msv.grammar.util.ExpressionWalker.onSequence(ExpressionWalker.java:69)
at com.sun.msv.grammar.SequenceExp.visit(SequenceExp.java:24)
at com.sun.msv.grammar.util.ExpressionWalker.onBinExp(ExpressionWalker.java:73)
at com.sun.msv.grammar.util.ExpressionWalker.onChoice(ExpressionWalker.java:65)
at com.sun.msv.grammar.ChoiceExp.visit(ChoiceExp.java:26)
at com.sun.msv.grammar.util.ExpressionWalker.onBinExp(ExpressionWalker.java:74)
at com.sun.msv.grammar.util.ExpressionWalker.onSequence(ExpressionWalker.java:69)
at com.sun.msv.grammar.SequenceExp.visit(SequenceExp.java:24)
at com.sun.msv.grammar.util.ExpressionWalker.onBinExp(ExpressionWalker.java:73)
at com.sun.msv.grammar.util.ExpressionWalker.onChoice(ExpressionWalker.java:65)
at com.sun.msv.grammar.ChoiceExp.visit(ChoiceExp.java:26)
at com.sun.msv.grammar.util.ExpressionWalker.onBinExp(ExpressionWalker.java:74)
at com.sun.msv.grammar.util.ExpressionWalker.onSequence(ExpressionWalker.java:69)
at com.sun.msv.grammar.SequenceExp.visit(SequenceExp.java:24)
...

I will attach the SOA schema and the mpeg7 schemas as well as Ant output with
verbose/debug.

Apache Ant version 1.6.2 compiled on July 16 2004
Apache Ant version 1.6.2 compiled on July 16 2004
Buildfile: build.xml
Detected Java version: 1.4 in: C:\j2sdk1.4.2_06\jre
Detected OS: Windows XP
parsing buildfile C:\Projects\dev.java.net\hyperjaxb\tests\build.xml with URI =
file:///C:/Projects/dev.java.net/hyperjaxb/tests/build.xml
Project base dir set to: C:\Projects\dev.java.net\hyperjaxb\tests
Build sequence for target `test' is [test]
Complete build sequence is [test, clean, clean.all, roundtrip, leadIn, test.all, ]

test:
Project base dir set to: C:\Projects\dev.java.net\hyperjaxb\tests\soa
[ant] calling target [default] in build file
C:\Projects\dev.java.net\hyperjaxb\tests\test.build.xml
parsing buildfile C:\Projects\dev.java.net\hyperjaxb\tests\test.build.xml with
URI = file:///C:/Projects/dev.java.net/hyperjaxb/tests/test.build.xml
Project base dir set to: C:\Projects\dev.java.net\hyperjaxb\tests\soa
[ant] Entering C:\Projects\dev.java.net\hyperjaxb\tests\test.build.xml...
Build sequence for target `test' is [init, clean, generate.sources, compile,
jar, generate.hibernate.mapping, export.database.schema, generate, roundtrip, test]
Complete build sequence is [init, clean, generate.sources, compile, jar,
generate.hibernate.mapping, export.database.schema, generate, roundtrip, test, ]

init:

clean:
[delete] Deleting directory
C:\Projects\dev.java.net\hyperjaxb\tests\soa\generated.sources
[delete] Deleting directory
C:\Projects\dev.java.net\hyperjaxb\tests\soa\generated.sources

generate.sources:
[mkdir] Created dir:
C:\Projects\dev.java.net\hyperjaxb\tests\soa\generated.sources
[xjc] build id of XJC is 1.0.4-b16-fcs
[xjc] Consider using / so that XJC won't do unnecessary
compilation
[xjc] Checking timestamp of
C:\Projects\dev.java.net\hyperjaxb\tests\soa\schema\SOA.xsd
[xjc] the last modified time of ths inputs is 1109238759984
[xjc] the last modified time of the outputs is -9223372036854775808
[xjc] Compiling
file:/C:/Projects/dev.java.net/hyperjaxb/tests/soa/schema/SOA.xsd
[xjc] [INFO] Using Xerces from
jar:file:/C:/Projects/dev.java.net/hyperjaxb/lib/jaxb-1.4/xercesImpl.jar!/com/sun/org/apache/xerces/internal/impl/Version.class
[xjc] unknown location

[ant] Exiting C:\Projects\dev.java.net\hyperjaxb\tests\test.build.xml.

BUILD FAILED
C:\Projects\dev.java.net\hyperjaxb\tests\build.xml:46: The following error
occurred while executing this line:
java.lang.StackOverflowError
at
org.apache.tools.ant.ProjectHelper.addLocationToBuildException(ProjectHelper.java:539)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:388)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
at org.apache.tools.ant.Main.runBuild(Main.java:673)
at org.apache.tools.ant.Main.startAnt(Main.java:188)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)
Caused by: java.lang.StackOverflowError
at org.apache.tools.ant.Project.executeTarget(Project.java:1223)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:386)
... 10 more
Caused by: java.lang.StackOverflowError
โ€” Nested Exception โ€”
java.lang.StackOverflowError
at org.apache.tools.ant.Project.executeTarget(Project.java:1223)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:386)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
at org.apache.tools.ant.Main.runBuild(Main.java:673)
at org.apache.tools.ant.Main.startAnt(Main.java:188)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)
Caused by: java.lang.StackOverflowError
โ€” Nested Exception โ€”
java.lang.StackOverflowError

Total time: 2 seconds

Environment

Operating System: All
Platform: All

Affected Versions

[JWSDP1.4 (JAXB1.0.3)]

Exception when Unmarshalling an element with int list as value

There appears to be an element unmarshalling problem that manifests itself when
an element declared from an extension of xsd:list itemType=xsd:int is parsed. The
unmarshalling of the element fails only when this element has 1 or more attributes
as defined by its schema. Furthermore it fails only when the attribute usage for
these is use="required".

Investigation so far indicates the following:

The xjc generated class for the xsd:list derived element has its Unmarshaller inner
class set the stateTextTypes variable of its super class
(AbstractUnmarshallingEventHandlerImpl) to a String that is inconsistent with the
state that should correspond to the listState when tested in the super class'
isListState() method during the unmarshalling of the instance file.

This leads to the element's value String e.g. "1 0 16" being parsed as an Integer
directly rather than first being tokenised.

This problem has been found with the JAXB 1.02 shipped with JWSDP-1.3 and still
exists in the weekly build jaxb-ri-20031215. I do not believe this problem existed
with JAXB 1.0 but cannot confirm this with certainty.

Environment

Operating System: Windows 2000
Platform: PC
URL: https://jaxb.dev.java.net/servlets/ReadMsg?list=users&msgId=52152

Affected Versions

[JWSDP1.3 (JAXB1.0.2)]

Catalog resolver doesn't seem to work with XJC

Problem getting the Entity Resolver working with XJC. I am
using JAXB version 1.02 and Windows XP.

In my bindings file (JAXBBinding3.xjb) I have the following:

<jxb:bindings schemaLocation="datatypes.xsd" >

where datatypes.xsd is the schema that has name collisions.

In my catalog file (catalog.cat) I have the following

SYSTEM "datatypes.xsd"
"file:///C:/WSAD-IE5-WS/Workspace-01/JAXB/dt/datatypes.xsd"

and my xjc command is as follows:

C:\Data\etp>xjc -b JAXBBinding3.xjb -catalog catalog.cat ......

but I get the error
[ERROR] "file:/C:/Data/etp/datatypes.xsd" is not a part of this
compilation
line 4 of JAXBBinding3.xjb

Environment

Operating System: Windows XP
Platform: All

Affected Versions

[JWSDP1.3 (JAXB1.0.2)]

XJC does not fail when binding file is missing.

XJC does not fail when binding file is missing.

For example, in this Ant fragment:






<produces
dir="${java.source.dir}

/$

{server.backend.package.slash}/hsc/bind"
includes="${produces.files}"/>
<produces
dir="${java.source.dir}/${server.backend.package.slash}

/cics/bind"
includes="$

{produces.files}"/>
<produces
dir="${java.source.dir}/${server.backend.package.slash}/ims/bind"
includes="${produces.files}

"/>

<arg value="$

{runtime.package}

"/>

The file refered to by:

<binding dir="src/server/backend" includes="$

{binding.file}

"/>

Does not exist and the XJC or the Ant task does not complain. This is a problem
because bindings that are supposed to kick in do not and my client code no
longer compiles until my brain engages and realizes I need to pick up the
binding file from our repository.

Environment

Operating System: Windows XP
Platform: PC

Affected Versions

[JWSDP1.6 (JAXB1.0.5)]

boolean with pattern not being marshalled properly

I am using an industry standard schema with the following definition:

<xsd:complexType name="Boolean">
xsd:simpleContent
<xsd:extension base="Boolean_NoID">
<xsd:attribute name="id" type="ID"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<xsd:simpleType name="Boolean_NoID">
<xsd:restriction base="xsd:boolean">
<xsd:pattern value="\d"/>
</xsd:restriction>
</xsd:simpleType>

Elements of this type must have a value of 1 for true and 0 for false. JAXB
correctly unmarshalls such elements from an xml document into a boolean value,
but on marshall, creates element values of "true" or "false", which fail schema
validation.
Shouldn't jaxb marshall based on the pattern defined in the schema? If not, is
there a documented work-around?

Environment

Operating System: Windows 2000
Platform: PC

Affected Versions

[JWSDP1.6 (JAXB1.0.5)]

Unmarshaller dies after skipping illegal content

The attached sample tries to force the unmarshaller to continue
after processing "ABC" where a non-negative integer is expected.

There are two SimpleTypes defined in the schema, one of which
is annotated with a custom datatype converter. Run the schema
once as is, then modify the definition of "quantity" to be of
type MyAnnotatedInt and run again to see the exception.

Environment

Operating System: All
Platform: All

Affected Versions

[JWSDP1.6 (JAXB1.0.5)]

Valid Elements after the first in-valid element are rejected as un-expected elements

I am currently using XMLPullParser solution to unmarshall a source XML File into
JAXB Objects. The source XML can be successfully parsed into JAXB Objects if
there are no un-expected elements.

However, if there are un-expected elements in the source XML I would like to
warn the user, ignore the element, and proceed with the processing of rest of
XML. Instead, the JAXB reports properly the un-expected element through
ValidationEvent, but from then on it reports all the valid elements in the XML
as un-expected elements. If I introduce the in-valid element as a last element
in source XML, all the prior elements in the source XML are properly
un-marshalled into the JAXB Object, while throwing out the last element as
un-expected

After a little bit of digging, I found that when an in-valid element is
encountered JAXB creates the instance of Discarder class to deal with this
element. However the Discarder seems to be not re-setting the "state" variable
being used in unmarshaller appropriately for the elements that follows the
in-valid element, hence even the valid elements will not processed!

Is there another mechanism I can use to ignore the in-valid element and proceed
with the other valid elements in source XML?

The XMLPullUnmarshaller is coded as follows:

public XMLPullUnmarshaller(JAXBContext context, XmlPullParser prsr) throws
JAXBException {
unmarshaller = context.createUnmarshaller();

unmarshaller.setEventHandler(new ValidationEventHandler(){
public boolean handleEvent(ValidationEvent event)

{ System.out.println("Ignoring Element:" +parser.getName()); return true; }

});

parser = prsr;
handler = unmarshaller.getUnmarshallerHandler();
}

Environment

Operating System: Windows 2000
Platform: PC

Affected Versions

[JWSDP1.3 (JAXB1.0.2)]

large schema: [ERROR] Unsupported binding namespace "p182060_"

Attempting to parse large schema

java -Xmx800m -Xss10m -jar %JAXB_HOME%\jaxb-xjc.jar -nv -p com.bwalsh.jaxbTst -
d ..\java acord-pc-v1_7_0-ns-nodoc-codes.xsd -b
acordBinding.xjb -extension
parsing a schema...
[ERROR] Unsupported binding namespace "p182060_"
line 51 of file:/C:/source/jaxbTst2.0/src/schemas/acord-pc-v1_7_0-ns-nodoc-cod
es.xsd

Failed to parse a schema.
#######
acordBinding.xjb
#######
<jxb:bindings version="1.0"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"

<jxb:bindings schemaLocation="acord-pc-v1_7_0-ns-nodoc-codes.xsd"
node="/xs:schema">

###########

##########
acord-pc-v1_7_0-ns-nodoc-codes.xsd
##########

#### Environment
Operating System: Windows 2000
Platform: All
#### Affected Versions
[2.0 EA1]

Performance Improvement in NamespaceContextImpl.java

The requirePrefix check after the first else condition in declareNamespace
method can be changed to !requirePrefix check so that the method is quickly
returned without un-necessary code exectution.

Currently JAXB generates as follows..

public String declareNamespace( String namespaceUri, String preferedPrefix,
boolean requirePrefix ) {
if( !inCollectingMode )

{ if (!requirePrefix && nss.getURI("").equals(namespaceUri) ) return ""; // can use the default prefix. use it whenever we can ... } else {
if(requirePrefix && namespaceUri.length()==0 )
return "";

Instead there is is substantial performance improvement if JAXB generates the
method as follows!

public String declareNamespace( String namespaceUri, String preferedPrefix,
boolean requirePrefix ) {
if( !inCollectingMode ) { if (!requirePrefix && nss.getURI("").equals(namespaceUri) ) return ""; // can use the default prefix. use it whenever we can ... }

else {
if(!requirePrefix && namespaceUri.length()==0 )
return "";

Environment

Operating System: Windows 2000
Platform: PC

Affected Versions

[JWSDP1.3 (JAXB1.0.2)]

Code too large error after running JAXB on large schema.

hi
After running a large schema through the latest weekly builds (which fixed a
memory error) the java files were created successfully. But when I try and
compile them I get the errors:

[code]
Compiling from src/interfaces [classpath=]
Compiling 7695 source files to C:\dev\projectm\classes
C:\dev\projectm\src\interfaces\com\letsys\erespond\interfaces\JAXBLibs\OutageRecord\ObjectFactory.java:10330:
code too large
private static void __$$init$$1() {
^
C:\dev\projectm\src\interfaces\com\letsys\erespond\interfaces\JAXBLibs\OutageRecord\ObjectFactory.java:74979:
code too large
private static void __initRootMap1() {
^
2 errors
[/code]

The method is about 3000-4000 lines long. I don't have any idea on how to fix
this, but I guess I will need to work on a workaround myself for the minute
until JAXB can cope with large schemas.

Cheers
Robert.

Environment

Operating System: All
Platform: All

Affected Versions

[JWSDP1.6 (JAXB1.0.5)]

XJC fails with attribute named as component

XJC fails when there is an element that has attribute named as "Content" in the
schema to be compiled. Here's an example of from IOTP schema:

-cut-
<xs:element name="PackagedContent">
<xs:complexType mixed="true">
<xs:attribute name="Name"/>
<xs:attribute name="Content" default="PCDATA" type="xs:NMTOKEN"/>
<xs:attribute name="Transform" default="NONE">
xs:simpleType
<xs:restriction base="xs:token">
<xs:enumeration value="NONE"/>
<xs:enumeration value="BASE64"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
-cut-

XJC outputs:

-cut-
compile-xml:
[echo] Compiling the IOTP schema..
[xjc] Compiling file:/home/jyrki/cvs/Engineering/IOTPAdapter/iotp.xsd
[xjc] [ERROR] A property with the same name "Content" is generated from
more than one schema component.
[xjc] line 117 of iotp.xsd
-cut-

Environment

Operating System: All
Platform: All

Affected Versions

[JWSDP1.3 (JAXB1.0.2)]

JAXB treating default and explicit namespace differently

Hi,

I am using jaxb 1.0.4 from jwsdp 1.5 , I have a pretty complicated schema from
ogc

(http://schemas.opengis.net/wcs/1.0.0/) and was successful using xjc to
generate some java code

I have two issues

Issue 1 Different treatment form explicit name space and default namespace.

I have an instance document , if I use default namespace the deserialization
fail, but if I change the default namespace to non default namespace (i.e.with
a prefix) , jaxb has no problem parsing the xml.

What would cause this problem?

Most of the document I receive will be using default namespace, Is there a way
to work around this problem?

Issue 2 JAXB seems to have problem support several levels of type
extension/restriction

When I try to un-marshal some valid xml (checked with xml spy)

I run into an exception,

javax.xml.bind.UnmarshalException: Unexpected element

{http://www.opengis.net/wcs}

:label

when this element is at the right place

I debug into some jaxb generated code in
impl.runtime.SAXUnmarshallerHandlerImpl.java

The private UnmarshallingEventHandler[] handlers instance variable

Has 9 handlers some of them replicate the type hierarchy in the schema document
(see diagram).

I saw handlers[8] was used first, then handlers[7] , then handlers[6] and so on

For whatever reason (I suspect a bug) , once handler[5]

was used , it did not pop continue the stack to use handler[4] which will
handle the element

Instead it the control flow form handler[5] entertElement method to
super.enterElement which invoke unexpectedEnterElement method

I know there is a lot of details here, I would like to find out how can get
some support and may be confirm this is a bug.

The online schema as some issue and I have make some local changes so xjc can
generate the code.

I can send you the schema, instance doc for you reproduce the issue.

Thanks for listening.

Ivan Cheung

Environment

Operating System: Windows XP
Platform: PC

Affected Versions

[JWSDP1.4 (JAXB1.0.3)]

XJC causes a Java stack overflow with element renaming in the bindings file

I get a stack overflow when running xjc on the schema below with a bindings
file (also below). Using the debug option, it appears that xjc has got into an
infinite recursion.

The problem goes away if either the renaming is taken out of the bindings file,
or the nillable="true" is taken out of the schema.

The schema is:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.bbc.co.uk/rd/test" elementFormDefault="qualified"
attributeFormDefault="unqualified" version="1.0" xml:lang="EN">
<xs:element name="UserKey" nillable="true">
xs:complexType
<xs:attribute name="value" type="xs:string"
use="optional" default="Enter"/>
</xs:complexType>
</xs:element>
</xs:schema>

The bindings file is:
<jxb:bindings version="1.0" xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jxb:extensionBindingPrefixes="xjc">

<jxb:bindings schemaLocation="schema.xsd" node="/xs:schema">
<jxb:bindings node="//xs:element[@name='UserKey']">
<jxb:class name="UserKeyElement"/>
</jxb:bindings>
</jxb:bindings>
</jxb:bindings>

I'm running xjc using this command:
java -jar /project/jaxb_2_0/jaxb-ri-20050407/lib/jaxb-xjc.jar -d java -b
bindings.xjb schema.xsd

I've had the problem using both Windows 2000, and Solaris 9.

Here's an excerpt from the stack trace - it repeats after this.

at com.sun.xml.xsom.impl.ElementDecl.apply(ElementDecl.java:203)
at com.sun.tools.xjc.reader.xmlschema.ClassSelector._bindToClass
(ClassSelector.java:312)
at com.sun.tools.xjc.reader.xmlschema.ClassSelector.bindToType
(ClassSelector.java:256)
at com.sun.tools.xjc.reader.xmlschema.ClassSelector.isBound
(ClassSelector.java:244)
at com.sun.tools.xjc.reader.xmlschema.DefaultClassBinder.complexType
(DefaultClassBinder.java:93)
at com.sun.tools.xjc.reader.xmlschema.DefaultClassBinder.complexType
(DefaultClassBinder.java:49)
at com.sun.tools.xjc.reader.xmlschema.ClassBinderFilter.complexType
(ClassBinderFilter.java:51)
at com.sun.tools.xjc.reader.xmlschema.Abstractifier.complexType
(Abstractifier.java:19)
at com.sun.tools.xjc.reader.xmlschema.Abstractifier.complexType
(Abstractifier.java:13)
at com.sun.xml.xsom.impl.ComplexTypeImpl.apply(ComplexTypeImpl.java:216)
at com.sun.tools.xjc.reader.xmlschema.ClassSelector._bindToClass
(ClassSelector.java:312)
at com.sun.tools.xjc.reader.xmlschema.ClassSelector.bindToType
(ClassSelector.java:285)
at com.sun.tools.xjc.reader.xmlschema.DefaultClassBinder.allow
(DefaultClassBinder.java:340)
at com.sun.tools.xjc.reader.xmlschema.DefaultClassBinder.elementDecl
(DefaultClassBinder.java:146)
at com.sun.tools.xjc.reader.xmlschema.DefaultClassBinder.elementDecl
(DefaultClassBinder.java:49)
at com.sun.tools.xjc.reader.xmlschema.ClassBinderFilter.elementDecl
(ClassBinderFilter.java:91)
at com.sun.tools.xjc.reader.xmlschema.Abstractifier.elementDecl
(Abstractifier.java:26)
at com.sun.tools.xjc.reader.xmlschema.Abstractifier.elementDecl
(Abstractifier.java:13)
at com.sun.xml.xsom.impl.ElementDecl.apply(ElementDecl.java:203)
at com.sun.tools.xjc.reader.xmlschema.ClassSelector._bindToClass
(ClassSelector.java:312)
at com.sun.tools.xjc.reader.xmlschema.ClassSelector.bindToType
(ClassSelector.java:256)
at com.sun.tools.xjc.reader.xmlschema.ClassSelector.isBound
(ClassSelector.java:244)
at com.sun.tools.xjc.reader.xmlschema.DefaultClassBinder.complexType
(DefaultClassBinder.java:93)
at com.sun.tools.xjc.reader.xmlschema.DefaultClassBinder.complexType
(DefaultClassBinder.java:49)
at com.sun.tools.xjc.reader.xmlschema.ClassBinderFilter.complexType
(ClassBinderFilter.java:51)
at com.sun.tools.xjc.reader.xmlschema.Abstractifier.complexType
(Abstractifier.java:19)
at com.sun.tools.xjc.reader.xmlschema.Abstractifier.complexType
(Abstractifier.java:13)
at com.sun.xml.xsom.impl.ComplexTypeImpl.apply(ComplexTypeImpl.java:216)
at com.sun.tools.xjc.reader.xmlschema.ClassSelector._bindToClass
(ClassSelector.java:312)
at com.sun.tools.xjc.reader.xmlschema.ClassSelector.bindToType
(ClassSelector.java:285)
at com.sun.tools.xjc.reader.xmlschema.DefaultClassBinder.allow
(DefaultClassBinder.java:340)
at com.sun.tools.xjc.reader.xmlschema.DefaultClassBinder.elementDecl
(DefaultClassBinder.java:146)
at com.sun.tools.xjc.reader.xmlschema.DefaultClassBinder.elementDecl
(DefaultClassBinder.java:49)
at com.sun.tools.xjc.reader.xmlschema.ClassBinderFilter.elementDecl
(ClassBinderFilter.java:91)
at com.sun.tools.xjc.reader.xmlschema.Abstractifier.elementDecl
(Abstractifier.java:26)
at com.sun.tools.xjc.reader.xmlschema.Abstractifier.elementDecl
(Abstractifier.java:13)
at com.sun.xml.xsom.impl.ElementDecl.apply(ElementDecl.java:203)
at com.sun.tools.xjc.reader.xmlschema.ClassSelector._bindToClass
(ClassSelector.java:312)
at com.sun.tools.xjc.reader.xmlschema.ClassSelector.bindToType
(ClassSelector.java:256)
at com.sun.tools.xjc.reader.xmlschema.ClassSelector.isBound
(ClassSelector.java:244)
at com.sun.tools.xjc.reader.xmlschema.DefaultClassBinder.complexType
(DefaultClassBinder.java:93)
at com.sun.tools.xjc.reader.xmlschema.DefaultClassBinder.complexType
(DefaultClassBinder.java:49)
at com.sun.tools.xjc.reader.xmlschema.ClassBinderFilter.complexType
(ClassBinderFilter.java:51)

Regards,

Steve

Environment

Operating System: All
Platform: All

Affected Versions

[2.0 EA1]

isNil and setNil methods are not always generated on nillable element

When the schema listed in the URL is compiled there is no isNil and setNil
method defined in the interface for the element multicast-interfaces. There is
another element in the schema that is nillable (the member-group element) and
the interface generated for that element gets a isNil and setNil method. The
strange thing is that when I also copy the member-group element to sequence of
the service-instance element that xjc refused to generate the isNil and setNil
method for that element too.

The schema has been validated with XMLSpy and the IBM Schema Quality Checker and
appears to be OK.

In case the binding files are required (this schema also includes a second
schema) please contact me to provide them.

The actual version of JAXB is 1.0.4 because JSWDP1.5 is not listed in the bug
system.

Environment

Operating System: All
Platform: All
URL: http://www.cheiron.org/schema/seven-config.xsd

Affected Versions

[JWSDP1.5 (JAXB1.0.4)]

Generated classes have a mixed file format

I've just downloaded the weekly build for 20050502, and the java files that it
generates contain the header, as normal, eg:
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB)
Reference Implementation, v2.0-05/02/2005 12:18 AM(kk122374)-EA

But then the class is a series of escaped characters, eg:
\u000d\u000a\u0070\u0061\u0063\u006b\u0061\u0067\u0065\u0020\u0070\u0063\u0066
\u003b\u000d\u000a

javac accepts these, so the classes seem to be intact within the encoding.
I've tried setting the file.encoding system property when running xjc, but it
has no effect. The problem happens on both Solaris 9 and Windows 2000.

Regards,

Steve

Environment

Operating System: All
Platform: All

Affected Versions

[2.0 EA1]

can't parse W3 SOAP 2003-05 envelope XML schema: "xml:lang" attr ref

I was trying to use JAXB to parse the MMAP schema from the SMS Forum
(http://www.smsforum.net/schemas/mmap/v1.0/mmap.xsd). I finally
tracked it down to XJC choking on the included SOAP envelope schema's
use of the xml:lang attribute for a tag called reasontext. Here's the
pared-down test case:

C:\java\src\baz>%JWSDP_HOME%\jaxb\bin\xjc.bat http://www.w3.org/2003/05/soap-
envelope/soap-envelope.xsd
%JWSDP_HOME%\jaxb\bin\xjc.bat http://www.w3.org/2003/05/soap-envelope/soap-
envelope.xsd
parsing a schema...
[ERROR] src-resolve: Cannot resolve the name 'xml:lang' to a attribute
declaration component.
line 97 of soap-envelope.xsd

[ERROR] src-ct.0.1: Complex Type Definition Representation Error for
type 'reasontext'. Element 'attribute' is invalid, misplaced, or occurs too
often.
line 97 of soap-envelope.xsd

Failed to parse a schema.
C:\java\src\baz>

I believe that the relevant portions of the schemas and namespaces in
question are:

http://www.w3.org/2003/05/soap-envelope/soap-envelope.xsd

<xs:complexType name="reasontext">
xs:simpleContent
<xs:extension base="xs:string">
<xs:attribute ref="xml:lang" use="required" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>

http://www.w3.org/2001/XMLSchema.xsd

<xs:complexType name="attribute" mixed="false">
xs:complexContent
<xs:extension base="xs:annotated">
xs:sequence
<xs:element name="simpleType" minOccurs="0" type="xs:localSimpleType" />
</xs:sequence>
<xs:attributeGroup ref="xs:defRef" />
<xs:attribute name="type" type="xs:QName" />
<xs:attribute name="use" use="optional" default="optional">
xs:simpleType
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="prohibited" />
<xs:enumeration value="optional" />
<xs:enumeration value="required" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="default" type="xs:string" />
<xs:attribute name="fixed" type="xs:string" />
<xs:attribute name="form" type="xs:formChoice" />
</xs:extension>
</xs:complexContent>
</xs:complexType>

http://www.w3.org/2001/XMLSchema.xsd

<xs:attributeGroup name="defRef">
xs:annotation
xs:documentationfor element, group and attributeGroup, which both define and
reference</xs:documentation>
</xs:annotation>
<xs:attribute name="name" type="xs:NCName" />
<xs:attribute name="ref" type="xs:QName" />
</xs:attributeGroup>

http://www.w3.org/XML/1998/namespace

The namespace whose name is http://www.w3.org/XML/1998/namespace is
bound by definition to the prefix xml: according to Namespaces in XML,
W3C Recommendation 14 Jan 1999. Note that unlike all other XML
namespaces, both the name and the prefix are specified; i.e., if you
want XML 1.0 processors to recognize this namespace, you must use the
reserved prefix xml:.

xml:lang and xml:space

As of the last update of this document, the XML 1.0 Specification
defines two attribute names in this namespace:

xml:lang

Designed for identifying the human language used in the scope of the
element to which it's attached.
.
.
.

I'm no XML schema expert, but it looks to me like "name" and "ref"
are both valid attributes for an xs:attribute tag and that the XML
namespace standard requires XML processors to recognize the xml:lang
attribute. From my newbie reading, this is not something to be fixed
in JSR 222/JAXB 2.0. So, this appears to me to be a bug in JAXB.

A secondary bug is that the original error message left the name of
the offending included schema blank:

C:\java\src\foo>d:\java\jwsdp\jwsdp-1.3\jaxb\bin\xjc.bat
http://www.smsforum.net/schemas/mmap/v1.0/mmap.xsd
parsing a schema...
[ERROR] src-resolve: Cannot resolve the name 'xml:lang' to a attribute
declaration component.
line 97 of

[ERROR] src-ct.0.1: Complex Type Definition Representation Error for
type 'reasontext'. Element 'attribute' is invalid, misplaced, or occurs too
often.
line 97 of

Failed to parse a schema.
C:\java\src\foo>

In case it helps with problem diagnosis, I'm running with J2SDK 1.4.2
and have copied the endorsed jar files into the JRE lib as instructured
with JAXB 1.0.2:

C:\java\src\baz>java -version
java -version
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)

C:\java\src\baz>dir %JAVA_HOME%\jre\lib\endorsed
dir %JAVA_HOME%\jre\lib\endorsed
Volume in drive D has no label.
Volume Serial Number is 70AE-6E52

Directory of D:\java\j2se\j2sdk1.4.2\jre\lib\endorsed

03/31/2004 09:41 AM

.
03/31/2004 09:41 AM ..
03/29/2004 01:28 PM 56,619 dom.jar
03/29/2004 01:28 PM 60,963 sax.jar
03/29/2004 01:28 PM 2,823,241 xalan.jar
03/29/2004 01:28 PM 2,667,618 xercesImpl.jar
10/10/2003 06:36 PM 1,379,810 xsltc.jar
6 File(s) 6,989,573 bytes
2 Dir(s) 7,889,731,584 bytes free

C:\java\src\baz>%JWSDP_HOME%\jaxb\bin\xjc.bat -version
xjc version "1.0.2-b15-fcs"
JavaTM Architecture for XML Binding(JAXB) Reference Implementation, (build
1.0.2-b15-fcs)
C:\java\src\baz>

I'm quite interested in the resolution of this issue as I'm stopped in
my tracks on progress here. Help with resolution, whether in JAXB or
my usage of it, will be much appreciated. I did a search of existing
issues but couldn't find a duplicate.

Environment

Operating System: All
Platform: All

Affected Versions

[JWSDP1.3 (JAXB1.0.2)]

ValidatorImpl does not initialize DatatypeConverter

ValidationImpl constructor does not set the DataTypeConverter as do the
Marshaller and Unmarshaller, resulting in NullPointerException (masked as
'false' results from validate) if a Validation.validate( ... ) is performed
before the first creation of a Marshaller or Unmarshaller. here's a test case
(tabstop=4, textwidth=120):

import com.somewhere.test.xml.bind.SimpleString;
import com.somewhere.test.xml.bind.RestrictedDouble;
import com.somewhere.test.xml.bind.ObjectFactory;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

import javax.xml.bind.Validator;

// this is a test case to point out that, if a validation is requested before a
marshal or an unmarshalling occurs, then
// we get exceptions (notably due to the fact that ValidationImpl constructor
doesn't call
// DatatypeConverter.setDatatypeConverter, as do Marshallers and Unmarshallers.
interestingly enough, this only seems to
// be the case with doubles, not strings (haven't tried any other types).
//
// here's the schema for the tests below:
//
//
//
//
// <xsd:schema targetNamespace="http://somewhere.com/test/xml/bind"
// xmlns:test="http://somewhere.com/test/xml/bind"
// xmlns:xsd="http://www.w3.org/2001/XMLSchema">
//
// <xsd:complexType name="SimpleStringType">
// xsd:sequence
// <xsd:element name="Value" type="xsd:string"/>
// </xsd:sequence>
// </xsd:complexType>
//
// <xsd:element name="SimpleString" type="test:SimpleStringType"/>
//
// <xsd:complexType name="RestrictedDoubleType">
// xsd:sequence
// <xsd:element name="Value">
// xsd:simpleType
// <xsd:restriction base="xsd:double">
// <xsd:minInclusive value="0"/>
// <xsd:maxInclusive value="200"/>
// </xsd:restriction>
// </xsd:simpleType>
// </xsd:element>
// </xsd:sequence>
// </xsd:complexType>
//
//
// <xsd:element name="RestrictedDouble" type="test:RestrictedDoubleType"/>
//
// </xsd:schema>
//
// all of this is done using java 1.4, jwsdp 1.4 on a powerbook. output from
xjc.sh -version:
//
// JavaTM Architecture for XML Binding(JAXB) Reference Implementation,
(build 1.0.3-b18-fcs)
//

public class ValidateFirstTestCase extends TestCase {

public ValidateFirstTestCase()

{ super(); }

public static Test suite()

{ return new TestSuite( ValidateFirstTestCase.class ); }

// this will succeed.
public void testValidateString() throws Exception

{ ObjectFactory of = new ObjectFactory(); SimpleString ss = of.createSimpleString(); ss.setValue( "hello there" ); Validator validator = of.createValidator(); assertTrue( validator.validate( ss ) ); }

// this won't.
public void testValidateDouble() throws Exception

{ ObjectFactory of = new ObjectFactory(); RestrictedDouble dbl = of.createRestrictedDouble(); dbl.setValue( 120 ); Validator validator = of.createValidator(); assertTrue( validator.validate( dbl ) ); }

public void testValidateDoubleAfterMarshallerConstructor() throws Exception

{ ObjectFactory of = new ObjectFactory(); of.createMarshaller(); // just to execute the necessary line in the constructor. // now, the above test will work. testValidateDouble(); }

public static void main( String[] args )

{ junit.textui.TestRunner.run( suite() ); }

}

Environment

Operating System: All
Platform: Macintosh

Affected Versions

[JWSDP1.4 (JAXB1.0.3)]

Most minor defect ever

com.sun.xml.bind.serializer.AbortSerializationException: A tree contains a
reference to ID "WayPoint3634" but its not a part of the object graph

"its" is possessive.
"it's" is "it is".

That's it. That's the bug. I think that's the smallest ever. Everything else
seems to work great.

Environment

Operating System: All
Platform: All

Affected Versions

[JWSDP1.4 (JAXB1.0.3)]

Invalid default value used for attribute

XJC reports an error:

[ERROR] The value specified in the default attribute "v1.0" is not a valid value
for the datatype
line 11 of TestSchema.xsd

for the following schema:

<xsd:schema targetNamespace='http://www.test.net/v1'
xmlns='http://www.test.net/v1' xmlns:xsd='http://www.w3.org/2001/XMLSchema'
elementFormDefault='qualified' attributeFormDefault='unqualified'
version='v1.0'>
<xsd:element name='Base' type='BaseType'/>
<xsd:complexType name='BaseType'>
<xsd:attribute ref='myVer' use='required'/>
<xsd:attribute ref='score' use='optional'/>
</xsd:complexType>
<xsd:attribute name='myVer' type='xsd:string' default="v1.0"/>
<xsd:attribute name='score' type='xsd:decimal'/>
</xsd:schema>

If default value for myVer is changed to "1.0" ( decimal ) code is generated
successfully.
If score attribute is changed to xsd:string code is generated successfully.
If any valid default value is assigned to score code is generated successfully.

Environment

Operating System: Windows XP
Platform: PC

Affected Versions

[JWSDP1.6 (JAXB1.0.5)]

xjc:type="complex", xsd:ID and com.sun.xml.bind.IdentifiableObject

I'm working with jaxb 1.0.2.

I'm trying to use <xjc:typeSubstitution type="complex"> for some objects
with xsd:ID and xsd:IDREF attributes. Just adding the tag breaks things.
(Removing it fixes the problems, but then I can't use the feature.)

Inside of the jaxb-generated TypeImpl.java, the code tries to cast the
xsd:IDREF instances to com.sun.xml.bind.marshaller.IdentifiableObjects.

But the objects don't implement the interface, so I get a
ClassCastException (took some digging to find it.
Util.handlePrintConversionException looses it inside an
AbortSerializationException).

IDs work fine without <xjc:typeSubstitution type="complex">. (I need
the typeSubstitution to give the jaxb-gnerated objects some behavior.)

You should be able to reproduce the problem by running this test case, that
combines a build script, JUnit test, schema and some support classes.

Thanks for taking care of us,

Dave and Jeremy


Directory structure for the test case:

jaxb-bug-report

  • build.xml
    • source
    • com
    • alphatech
    • jaxb
    • report
  • MySmallThingImpl.java
  • MySpecialSmallThingImpl.java
    • test
  • TypeSubstitutionTest.java
    • xml
  • jaxb-bug.xsd
  • jaxb-javadoc.xslt

โ€”
build.xml:

<property file="$

{common}/source/properties/override-build.properties" />

<property file="${common}

/source/properties/build.properties" />





<mkdir dir="${compiled}

/jaxb-bug" />
<javac destdir="$

{compiled}/jaxb-bug" deprecation="yes" debug="yes" >















<copy todir="${compiled}

/jaxb-bug" overwrite="true">
<fileset dir="$

{build}/jaxb-java" >

























<sysproperty key="testdir" value="$

{build}

/test-area"/>


<pathelement path="$

{product-jar}

" />
<pathelement path="$

{product-test-jar}

" />
<pathelement path="$

{junit-jar}

" />
<pathelement path="$

{jaxb-jar}

" />
<pathelement path="$

{jaxb-impl-jar}

" />
<pathelement path="$

{jaxb-libs-jar}

" />
<pathelement path="$

{jaxp-xercesImpl-jar}

" />
<pathelement path="$

{jaxb-namespace-jar}

" />
<pathelement path="$

{jaxb-relaxngDatatype-jar}

" />
<pathelement path="$

{jaxb-xsdlib-jar}

"/>
<pathelement path="$

{jaxb-jax-qname-jar}

"/>




MySpecialThingImpl.java:

package com.alphatech.jaxb.report;

public class MySmallThingImpl
extends com.alphatech.jaxb.report.impl.SmallThingTypeImpl
{

public MySmallThingImpl()

{ super(); }

}


MySpecialSmallThingImpl.java:

package com.alphatech.jaxb.report;

public class MySpecialSmallThingImpl
extends com.alphatech.jaxb.report.impl.SpecialSmallThingTypeImpl
{

public MySpecialSmallThingImpl()
{ super(); }

}


TypeSubstitutionTest.java:

package com.alphatech.jaxb.report.test;

import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.StringWriter;
import java.io.StringReader;
import java.io.Reader;

import javax.xml.transform.stream.StreamSource;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;

import junit.framework.TestCase;
import junit.framework.Test;
import junit.framework.TestSuite;

import com.alphatech.jaxb.report.Example;
import com.alphatech.jaxb.report.ObjectFactory;

//import com.alphatech.jaxb.report.impl.BigThingTypeImpl;
//import com.alphatech.jaxb.report.impl.BigThingImpl;
import com.alphatech.jaxb.report.BigThing;
import com.alphatech.jaxb.report.SmallThing;
import com.alphatech.jaxb.report.SpecialSmallThing;
import com.alphatech.jaxb.report.SpecialSmallThingType;
import com.alphatech.jaxb.report.MySmallThingImpl;

public class TypeSubstitutionTest
extends TestCase
{
public TypeSubstitutionTest(String testName)

{ super(testName); }

public void testRoundTrip()
{
ObjectFactory of = new ObjectFactory();
try

{ Example example = of.createExample(); JAXBContext jc = JAXBContext.newInstance("com.alphatech.jaxb.report"); Marshaller marshaller = jc.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,Boolean.TRUE); StringWriter writer = new StringWriter(); marshaller.marshal(example,writer); // marshaller.marshal(agent,System.out); Unmarshaller unmarshaller = jc.createUnmarshaller(); unmarshaller.setValidating( true ); Reader reader = new StringReader(writer.toString()); Example newExample = (Example)unmarshaller.unmarshal(new StreamSource(reader)); }

catch(JAXBException jaxbe)

{ jaxbe.printStackTrace(); fail(jaxbe.getMessage()); }
}

public void testRoundTripWithAdd()
{
ObjectFactory of = new ObjectFactory();
try
{ Example example = of.createExample(); // add a BigThing to example. BigThing bigThing = of.createBigThing(); SmallThing smallThing = of.createSmallThing(); bigThing.getSmallThing().add(smallThing); SpecialSmallThingType ssT = of.createSpecialSmallThingType(); bigThing.getSmallThing().add(ssT); example.getBigThing().add(bigThing); JAXBContext jc = JAXBContext.newInstance("com.alphatech.jaxb.report"); Marshaller marshaller = jc.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,Boolean.TRUE); StringWriter writer = new StringWriter(); marshaller.marshal(example,writer); // marshaller.marshal(agent,System.out); Unmarshaller unmarshaller = jc.createUnmarshaller(); unmarshaller.setValidating( true ); Reader reader = new StringReader(writer.toString()); Example newExample = (Example)unmarshaller.unmarshal(new StreamSource(reader)); }
catch(JAXBException jaxbe)
{ jaxbe.printStackTrace(); fail(jaxbe.getMessage()); }

}

public void testCustomSmallType()
{
ObjectFactory of = new ObjectFactory();

try

{ BigThing bigThing = of.createBigThing(); System.out.println("created BigThing"); // bigThing.setSmallthing(new MySmallThingImpl()); SmallThing smallThing = of.createSmallThing(); System.out.println("created SmallThing"); // bigThing.setSmallthing(smallThing); bigThing.getSmallThing().add(smallThing); System.out.println("set SmallThing"); SpecialSmallThingType ssT = of.createSpecialSmallThingType(); System.out.println("created sst"); bigThing.getSmallThing().add(ssT); System.out.println("set ssT"); }

catch(JAXBException jaxbe)

{ jaxbe.printStackTrace(); fail(jaxbe.getMessage()); }

}

public static Test suite()

{ TestSuite suite = new TestSuite(); suite.addTest(new TypeSubstitutionTest("testRoundTrip")); suite.addTest(new TypeSubstitutionTest("testRoundTripWithAdd")); // suite.addTest(new TypeSubstitutionTest("testCustomSmallType")); return suite; }

}


jaxb-bug.xsd:

<xsd:schema targetNamespace="http://alphatech.com/pct/plan"
xmlns="http://alphatech.com/pct/plan"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" elementFormDefault="qualified"
jaxb:extensionBindingPrefixes="xjc" jaxb:version="1.0">
xsd:annotation
xsd:appinfo
<jaxb:globalBindings fixedAttributeAsConstantProperty="true">
<xjc:typeSubstitution type="complex"/>
</jaxb:globalBindings>
jaxb:schemaBindings
<jaxb:package name="com.alphatech.jaxb.report">
jaxb:javadoc

This package contains JavaBean classes for reporting a bug to JaxB

<xsd:complexType name="SpecialSmallThingType">
xsd:annotation
xsd:appinfo
<jaxb:class implClass="com.alphatech.jaxb.report.MySpecialSmallThingImpl"/>
</xsd:appinfo>
</xsd:annotation>
xsd:complexContent
<xsd:extension base="SmallThingType">
<xsd:attribute name="token" type="xsd:token"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:element name="SpecialSmallThing" type="SpecialSmallThingType"
substitutionGroup="SmallThing">
</xsd:element>
</xsd:schema>


jaxb-javadoc.xslt:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb">

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="node()|@" >
xsl:copy
<xsl:copy-of select="@
"/>
<xsl:apply-templates />
</xsl:copy>
</xsl:template>

<xsl:template match="xsd:element/xsd:annotation/xsd:documentation">
xsd:appinfo
jaxb:class
jaxb:javadoc
xsl:apply-templates/
</jaxb:javadoc>
</jaxb:class>
</xsd:appinfo>
xsl:copy
<xsl:copy-of select="@*"/>
xsl:apply-templates/
</xsl:copy>
</xsl:template>

<xsl:template match="xsd:complexType/xsd:annotation/xsd:documentation">
xsd:appinfo
jaxb:class
jaxb:javadoc
xsl:apply-templates/
</jaxb:javadoc>
</jaxb:class>
</xsd:appinfo>
xsl:copy
<xsl:copy-of select="@*"/>
xsl:apply-templates/
</xsl:copy>
</xsl:template>

</xsl:stylesheet>

Environment

Operating System: All
Platform: All

Affected Versions

[JWSDP1.3 (JAXB1.0.2)]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.