users@jaxb.java.net

Re: trouble editing xjb file in eclipse. does not not about jaxb and xjc types.

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Wed, 30 May 2012 21:18:18 +0200

On 30/05/2012, Andy Davidson <andy_davidson_at_apple.com> wrote:
> Hi Wolfgang
>
> I did not explain what we are trying to do very well.

Aren't we all trying to do all things very well ;-) OK, I'll cut the jibes.

> We want to
> create/maintain/edit the xjb file using an XML, DTD, XSD aware editor like
> eclipse.

> These editors will make it much faster and easier for catch bugs.
> We build our project using Maven. For unknown reasons the xjc errors where
> not showing up in our build logs.

That's a Maven setup problem; shouldn't be a problem to route a
program's standard error into the log.

> I discovered the bugs by running xjc on
> the command line. You are correct. when run from the command line xjc did a
> good job of reporting errors. Most of the problems where related file name
> changes.
>
> Bellow is a more complete example of our actual xjc file. I deleted most of
> the contents. eclipse does not know what types are allowed. <jaxb:bug>hello
> world</jaxb:bug> will not cause an error.
>
> eclipse generates a wanring "No grammer constraints (DTD or XML Schema)
> detected for the document" thats it. As long as the xml is well formed
> eclipse does not complain.
>

[snip]

I'm afraid I can't help you with Eclipse's XML Schema aware XML
editing. I'm surprised to hear that this should be possible, but I'm
not relying on Eclipse support in my work.

> Given xjc process xsd files. I assume that xjc files would start with a
> proper <schema> tag and not use well formed XML.

"xjc file"? Do you mean a JAXB binding file? Why ever should it NOT
use well formed XML??

>
> Personally I find the xjc related documentation to be very difficult to find
> and use.

Calling xjc is documented in the JAXB download bundle in
./docs/xjc.html. A quick usage is available from xjc -help.

The contents of the bindings file is documented in The "JAXB
Specification", which is the fundamental documentation for JAXB.
http://download.oracle.com/otndocs/jcp/jaxb-2.0-fr-eval-oth-JSpec/

> My hope is that by adding the meta data to our xjb files that it
> will be easier for our programmers to figure out how the xjb file works.

A few basics are covered in Section 5,Customizing, of my JAXB tutorial.
http://jaxb.java.net/tutorial/

-W

>
> Thanks
>
> Andy
>
>
> On May 30, 2012, at 10:13 AM, Wolfgang Laun wrote:
>
>> On 30/05/2012, Andy Davidson <andy_davidson_at_apple.com> wrote:
>>> Hi
>>>
>>> I started working on a project that uses an xjb bind file. It looks like
>>> this file was written a long time ago and has some bugs.
>>
>> What makes you think so? Please provide xjc version, error messages,
>> source file?
>>
>>> I am using
>>> eclipse
>>>
>>> The original file starts out with
>>>
>>> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>>> <jaxb:bindings version="2.0"
>>> targetNamespace="http://www.apple.com/ist/retail/pos/common/pojo"
>>> xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
>>> xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
>>> xmlns:xs="http://www.w3.org/2001/XMLSchema"
>>> xmlns:pos="http://www.Apple.com/LAVA"
>>> jaxb:extensionBindingPrefixes="xjc">
>>>
>>> <jaxb:
>>> <jaxb:globalBindings>
>>> <xjc:simple />
>>> <xjc:serializable uid="-1" />
>>> </jaxb:globalBindings>
>>>
>>
>> Hardly, this isn't even well formed up to the truncated end.
>>
>>>
>>> eclipse has no knowledge about the jaxb types.
>>
>> There are no JAXB types. Do you mean the XML schema for JAXB binding
>> files? If so, why should Eclipse have any knowledge about it?
>>
>>>
>>> How should I convert the file so that eclipse is able to validate it?
>>
>> Do you have an XML Schema aware plugin for handling XML files?
>> Otherwise, just rely on xjc to find the errors. The diagnostics are
>> (most of the time) sufficient.
>>
>>
>>>
>>> I found a couple of example that looked sort of like
>>>
>>> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
>>> xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
>>> xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
>>> jaxb:extensionBindingPrefixes="xjc" jaxb:version="2.0"
>>>
>>> targetNamespace="http://www.apple.com/ist/retail/pos/common/pojo"
>>> xmlns:pos="http://www.Apple.com/LAVA">
>>>
>>>
>>> eclipse still has no knowledge about the jaxb types. I assume I need to
>>> add
>>> a schemaLocation attribute. What should the value be?
>>>
>>> I am not sure how to set the schemaLocation. I tried adding a
>>> xsi:schemaLocation attribute
>>>
>>> xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb
>>> http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"
>>
>> The second URL looks good.
>>
>>>
>>> I also tried adding an import tag.
>>> <xs:import namespace="http://java.sun.com/xml/ns/jaxb"
>>> schemaLocation="http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"
>>> />
>>>
>>> Still did not work.
>>
>> What did not work?
>>
>>>
>>> I have a similar problem with the xjc types.
>>
>> There's no such thing, or, rather, what do you think that "xjc types"
>> are?
>>
>> -W
>>
>>>
>>> Any suggestions would be greatly appreciated.
>>>
>>> Andy
>>>
>>>
>>>
>
>