tags:

views:

109

answers:

3

On my current project we generate JAXB beans from an XSD file. We need line number information on the beans (beyond XSD validation errors!) so I used the -Xlocator option specified here:

http://java.sun.com/webservices/docs/1.6/jaxb/xjc.html

However, I'm missing the Locator class. The jar file referenced to on that six-year old page can't be found anywhere, as I don't see a download for JWSDP on any site at all.

Is XJC dead? Should I be using something else?

Edit: solution has to use Java 1.5

+2  A: 

XJC is far from dead, but that page you're referencing is ancient, and applies to JAXB 1. Java6 contains JAXB 2.1 (see the docs here). It's annoying that when you do a google search today, most of the hits you get back are for obsolete JAXB 1 references.

I'm not sure what you're requirements are. What do you mean by "We need line number information on the beans"?

edit: You mentioned the @XmlLocation annotation. This is a non-standard annotation within both Java6 and the JAXB reference implementation, which you'll be using with Java5. The classname is com.sun.xml.bind.annotation.XmlLocation, and the javadoc is here. The reference implementation you can get from here, if you don't have it already.

skaffman
I want each bean to track where it came from in the XML file, i.e. the line and column numbers (line would be sufficient though).It appears as if XJC supports this (through -Xlocator) and JAXB seems to do so with the @XmlLocation annotation, but I can't get it to work without that dependency.If it's relevant: we're using java 1.5.
Wouter Lievens
@Wouter: See edit
skaffman
Thanks for the addendum, but ... maybe I'm stupid, but I can't find a proper download on that site. I can download a jar with a single ten megabyte class in it, but that's of little use to me. Where could I download the correct jar?
Wouter Lievens
A: 

I found the problem, or at least part of it. XJC generates imports to the "internal" package versions of XmlLocation and Locatable. Don't ask me why!

I wrote a little script to replace these imports with the correct ones, and it seems to work fine now.

Wouter Lievens
A: 

Wouter, I have the same issue. Can you please share the correct imports? Which jar file did you include to get it to work? Like you said, search results point to jaxb-locator-support.jar in jwsdp-1.6. I installed jwsdp-2.0 and it has no such jar file. Never mind, I corrected the package import. However, I get the line/column of the closing ">" of the element instead of opening "<".

itut