Sunday, September 14, 2008

Creating jaxb files from the opentravel schema

Probably the easiest way to deal with complicated xml documents is to use the jaxb tool from java. jaxb converts a schema definition from .xsd format to java classes. If you are trying to use jaxb on the opentravel.org schema there are a few gotchas:
  • First, since the schema is so large, there are a few places where there are duplicate element names.
  • Second, since the schema was not developed with jaxb in mind, there are a few element names (such as 'class') that are not legal in java.
Luckily, I wrote a utility that makes it a lot easier to use jaxb, called ota-schema-tools. This is part of the open source ota-tools project. You can download these tools at the sourceforge project page. After you have downloaded the tools, unzip them into a directory.

After a few quick steps, the schema tool is ready to go:
1. Download the sch
ema(s) that you want to use from opentravel.org and drop it in the ota-schema-zip-files directory:

2. Edit the ota.xsd file in the ota-schema-tools/config/2008A directory to include only the schema you will need (or leave it alone to compile all the schema). For example, here I only want to use the OTA_Ping messages:

3. Run the schema tool:
If jaxb is not in your classpath, you will need to tell ant where it is wi
th the -Djaxb.home=/location-of-jaxb-home flag. Also, if you are compiling a lot of schemas, you will have to set the ANT_OPTS=javac-options property. Here is what I type:
ota-schema-tools> export ANT_OPTS=-Xmx512m ota-schema-tools> ant -Djaxb.home=/usr/local/java/web/glassfish/ dist

When I run this command I get the error: OTA_TourInformation.xsd and OTA_RailAvailRS.xsd is not a part of this compilation.
No problem. The jaxb configuration file is set up to fix problems in the entire schema. Just remove these lines from the ota-schema-tools/config/2008A/jaxb/binding.xjb file:

I deleted these highlighted lines. Now run this line again from your command prompt:
ant -Djaxb.home=/usr/local/java/web/glassfish/ dist
Voila! Your schema are compiled and neatly packaged in a opentravel2008a.jar file.

Now that wasn't that hard, was it!

40 comments:

vilojona said...

Hello.

I've tried to download the OTA tools project but in sourceforge there is no file uploaded.

Do you know where I can find that software to download ?

Thanks a lot.

Unknown said...

Johnathan,
For now, you will have to go to http://ota-tools.svn.sourceforge.net/viewvc/ota-tools/

and click on 'Download GNU tarball'.

If you are using linux, you probably know how to untar an archive, if you are using windows, just google 'untar windows' for a list of utilities that can 'unzip' the archive.

I will try to get the ota-tools project admin to post a zip file.

Thanks

Don

lsri8088 said...

Hello,
I'm trying to create the schema api 2005B. I've also tested with the 2006A and 2008A (your example), but they always give me errors.

Can you help?

These are, after following your instructions, errors 2008A scheme:

[echo] /usr/java/jaxb"
[mkdir] Created dir: /home/arfernandez/Documents/incidencias/138 [Evento Tools, nuevo api OTA]/ota-tools/trunk/java/ota-schema-tools/build/2008A/temp/jaxb/src
[echo] Compiling the schema...
[xjc] Compiling file:/home/arfernandez/Documents/incidencias/138%20[Evento%20Tools,%20nuevo%20api%20OTA]/ota-tools/trunk/java/ota-schema-tools/build/2008A/temp/jaxb/schema/ota.xsd
[xjc] [ERROR] Property "Value" is already defined. Use <jaxb:property> to resolve this conflict.
[xjc] line 1011 of file:/home/arfernandez/Documents/incidencias/138%20%5BEvento%20Tools,%20nuevo%20api%20OTA%5D/ota-tools/trunk/java/ota-schema-tools/build/2008A/temp/jaxb/schema/OTA_SimpleTypes.xsd
[xjc]
[xjc] [ERROR] The following location is relevant to the above error
[xjc] line 489 of file:/home/arfernandez/Documents/incidencias/138%20%5BEvento%20Tools,%20nuevo%20api%20OTA%5D/ota-tools/trunk/java/ota-schema-tools/build/2008A/temp/jaxb/schema/OTA_RailAvailRS.xsd
[xjc]
[xjc] [ERROR] Property "Duration" is already defined. Use <jaxb:property> to resolve this conflict.
[xjc] line 165 of file:/home/arfernandez/Documents/incidencias/138%20%5BEvento%20Tools,%20nuevo%20api%20OTA%5D/ota-tools/trunk/java/ota-schema-tools/build/2008A/temp/jaxb/schema/OTA_TourInformation.xsd
[xjc]
[xjc] [ERROR] The following location is relevant to the above error
[xjc] line 355 of file:/home/arfernandez/Documents/incidencias/138%20%5BEvento%20Tools,%20nuevo%20api%20OTA%5D/ota-tools/trunk/java/ota-schema-tools/build/2008A/temp/jaxb/schema/OTA_CommonTypes.xsd
[xjc]
[xjc] failure in the XJC task. Use the Ant -verbose switch for more details

BUILD FAILED
/home/arfernandez/Documents/incidencias/138 [Evento Tools, nuevo api OTA]/ota-tools/trunk/java/ota-schema-tools/build.xml:87: The following error occurred while executing this line:
/home/arfernandez/Documents/incidencias/138 [Evento Tools, nuevo api OTA]/ota-tools/trunk/java/ota-schema-tools/build.xml:37: The following error occurred while executing this line:
/home/arfernandez/Documents/incidencias/138 [Evento Tools, nuevo api OTA]/ota-tools/trunk/java/ota-schema-tools/build.xml:24: The following error occurred while executing this line:
/home/arfernandez/Documents/incidencias/138 [Evento Tools, nuevo api OTA]/ota-tools/trunk/java/ota-schema-tools/buildspec.xml:190: unable to parse the schema. Error messages should have been provided

lsri8088 said...

Hello,
I'm trying to create the schema api 2005B. I've also tested with the 2006A and 2008A (your example), but they always give me errors.

Can you help?

These are, after following your instructions, errors 2008A scheme:

[echo] /usr/java/jaxb"
[mkdir] Created dir: /home/arfernandez/Documents/incidencias/138 [Evento Tools, nuevo api OTA]/ota-tools/trunk/java/ota-schema-tools/build/2008A/temp/jaxb/src
[echo] Compiling the schema...
[xjc] Compiling file:/home/arfernandez/Documents/incidencias/138%20[Evento%20Tools,%20nuevo%20api%20OTA]/ota-tools/trunk/java/ota-schema-tools/build/2008A/temp/jaxb/schema/ota.xsd
[xjc] [ERROR] Property "Value" is already defined. Use <jaxb:property> to resolve this conflict.
[xjc] line 1011 of file:/home/arfernandez/Documents/incidencias/138%20%5BEvento%20Tools,%20nuevo%20api%20OTA%5D/ota-tools/trunk/java/ota-schema-tools/build/2008A/temp/jaxb/schema/OTA_SimpleTypes.xsd
[xjc]
[xjc] [ERROR] The following location is relevant to the above error
[xjc] line 489 of file:/home/arfernandez/Documents/incidencias/138%20%5BEvento%20Tools,%20nuevo%20api%20OTA%5D/ota-tools/trunk/java/ota-schema-tools/build/2008A/temp/jaxb/schema/OTA_RailAvailRS.xsd
[xjc]
[xjc] [ERROR] Property "Duration" is already defined. Use <jaxb:property> to resolve this conflict.
[xjc] line 165 of file:/home/arfernandez/Documents/incidencias/138%20%5BEvento%20Tools,%20nuevo%20api%20OTA%5D/ota-tools/trunk/java/ota-schema-tools/build/2008A/temp/jaxb/schema/OTA_TourInformation.xsd
[xjc]
[xjc] [ERROR] The following location is relevant to the above error
[xjc] line 355 of file:/home/arfernandez/Documents/incidencias/138%20%5BEvento%20Tools,%20nuevo%20api%20OTA%5D/ota-tools/trunk/java/ota-schema-tools/build/2008A/temp/jaxb/schema/OTA_CommonTypes.xsd
[xjc]
[xjc] failure in the XJC task. Use the Ant -verbose switch for more details

BUILD FAILED
/home/arfernandez/Documents/incidencias/138 [Evento Tools, nuevo api OTA]/ota-tools/trunk/java/ota-schema-tools/build.xml:87: The following error occurred while executing this line:
/home/arfernandez/Documents/incidencias/138 [Evento Tools, nuevo api OTA]/ota-tools/trunk/java/ota-schema-tools/build.xml:37: The following error occurred while executing this line:
/home/arfernandez/Documents/incidencias/138 [Evento Tools, nuevo api OTA]/ota-tools/trunk/java/ota-schema-tools/build.xml:24: The following error occurred while executing this line:
/home/arfernandez/Documents/incidencias/138 [Evento Tools, nuevo api OTA]/ota-tools/trunk/java/ota-schema-tools/buildspec.xml:190: unable to parse the schema. Error messages should have been provided

Unknown said...

lsri8088,
The error you are getting is due to a problem in the design of the open travel schema. You should not get an error if you build the schema using the ant script in the ota-tools site. The ant script does an xsl transformation that fixes this problem before running the jaxb tool.
Don

lsri8088 said...

Hello,

True, I have solved it as you indicate.
Another mistake I had was related to the jaxb-api.jar version. I had to use the version of May 2005, for more recent versions XmlElementRef indicated that the method was not "required".

Thank you very much for your reply. Your post I have been helpful.

Greetings from Spain :)

Kyrto Gyz said...

Hi, I don't see build.xml from which to run the tool.

Kyrto Gyz said...

Hi, I don't see build.xml from which to run the tool.

Kyrto Gyz said...

Hi, I don't see build.xml from which to run the tool.

Unknown said...

Kyrto,

The build.xml file is in the git repository on sourceforge. You can clone the repository by typing:
git clone git://ota-tools.git.sourceforge.net/gitroot/ota-tools/ota-tools

If you are looking for java bindings for the opentravel schema, I would recommend using the bindings in the jibx schema library, here:
http://jibx.sourceforge.net/schema-library/opentravel/index.html

Hope this helps!

Don

amalEspoire said...

hi, i followed your steps but instead of glassfish i put tomcat then t got Build successful,
but i don't know where can i find the generated jar file

Unknown said...

Amal,
Try to use jaxb instead of glassfish. Download jaxb and enter the path to your jaxb installation:
ant -Djaxb.home=/path/to/jaxb/ dist
I hope this helps!
Don

Unknown said...

dist:

unzip:
[unzip] Expanding: /home/vinit/Docs/Hotel/ota-xsd/ota-schema-tools/ota-schema-zip-files/OTA2013A_Publication.zip into /home/vinit/Docs/Hotel/ota-xsd/ota-schema-tools/build/2013A/temp/unzip

moveschema:

moveotherschema:

movecodetable:

movetest:

moveflatschema:

movedocs:

copyall:

copybindings:
[xslt] Transforming into /home/vinit/Docs/Hotel/ota-xsd/ota-schema-tools/build/2013A/temp/jaxb/schema

fixall:

copycodetable:

jaxbschema:
[echo] Compiling the schema...
[xjc] Compiling file:/home/vinit/Docs/Hotel/ota-xsd/ota-schema-tools/build/2013A/temp/jaxb/schema/ota.xsd
[xjc] [ERROR] Property "Value" is already defined. Use <jaxb:property> to resolve this conflict.
[xjc] line 1830 of file:/home/vinit/Docs/Hotel/ota-xsd/ota-schema-tools/build/2013A/temp/jaxb/schema/OTA_Lists.xsd
[xjc]
[xjc] [ERROR] The following location is relevant to the above error
[xjc] line 6790 of file:/home/vinit/Docs/Hotel/ota-xsd/ota-schema-tools/build/2013A/temp/jaxb/schema/OTA_CommonTypes.xsd
[xjc]
[xjc] [ERROR] Property "Value" is already defined. Use <jaxb:property> to resolve this conflict.
[xjc] line 1846 of file:/home/vinit/Docs/Hotel/ota-xsd/ota-schema-tools/build/2013A/temp/jaxb/schema/OTA_Lists.xsd
[xjc]
[xjc] [ERROR] The following location is relevant to the above error
[xjc] line 7590 of file:/home/vinit/Docs/Hotel/ota-xsd/ota-schema-tools/build/2013A/temp/jaxb/schema/OTA_CommonTypes.xsd
[xjc]
[xjc] [ERROR] Property "Value" is already defined. Use <jaxb:property> to resolve this conflict.
[xjc] line 1846 of file:/home/vinit/Docs/Hotel/ota-xsd/ota-schema-tools/build/2013A/temp/jaxb/schema/OTA_Lists.xsd
[xjc]
[xjc] [ERROR] The following location is relevant to the above error
[xjc] line 5818 of file:/home/vinit/Docs/Hotel/ota-xsd/ota-schema-tools/build/2013A/temp/jaxb/schema/OTA_CommonTypes.xsd
[xjc]
[xjc] [ERROR] Property "Value" is already defined. Use <jaxb:property> to resolve this conflict.
[xjc] line 1846 of file:/home/vinit/Docs/Hotel/ota-xsd/ota-schema-tools/build/2013A/temp/jaxb/schema/OTA_Lists.xsd
[xjc]
[xjc] [ERROR] The following location is relevant to the above error
[xjc] line 5727 of file:/home/vinit/Docs/Hotel/ota-xsd/ota-schema-tools/build/2013A/temp/jaxb/schema/OTA_CommonTypes.xsd
[xjc]
[xjc] failure in the XJC task. Use the Ant -verbose switch for more details

BUILD FAILED
/home/vinit/Docs/Hotel/ota-xsd/ota-schema-tools/build.xml:92: The following error occurred while executing this line:
/home/vinit/Docs/Hotel/ota-xsd/ota-schema-tools/build.xml:33: The following error occurred while executing this line:
/home/vinit/Docs/Hotel/ota-xsd/ota-schema-tools/build.xml:24: The following error occurred while executing this line:
/home/vinit/Docs/Hotel/ota-xsd/ota-schema-tools/buildspec.xml:190: unable to parse the schema. Error messages should have been provided

config/binding.xjb for 2013A





















ota.xsd



Kindly help me

Thank you.

Unknown said...

Đấu Tôn cũng sắc mặt trầm xuống, chờ đợi Nhạc Thành phân phó.

- Các huynh đệ, mọi người xông lên đi, nhất định phải giết Cuồng Sư môn, Vạn Kim Môn, nữ nhân của Hồ Điệp cốc, Tuyệt Tình cốc sẽ là của chúng ta

- Ta nhìn thấy ở trong Hồ Điệp cốc và Tuyệt Tình cốc có rất nhiều người rất đẹp, mọi người mau tiến lê thanh âm nhơ lớp dongtam
mu moi ra hom nay
tim phong tro
http://nhatroso.com/
nhạc sàn
tổng đài tư vấn luật
văn phòng luật hà nội
tổng đài tư vấn luật
thành lập công ty trọn gói
http://we-cooking.com/
chém gió
trung tâm tiếng anhsong truyền tới, U Minh tông, Luyện Dược sư công hội những cường giả Đấu Tôn, còn có Đấu Hoàng Đấu Vương đều điên dại lao đến Hạo Đặc thành.

- Đại Song, Tiểu Song chuẩn bị bố trận.

Nhạc Thành cất tiếng nói, trên khuôn mặt của hắn nở ra một nụ cười.

- Nhạc Thành, chúng ta chuẩn bị nghênh địch sao?

Nhìn mảng khí tức bốc lên, Lê Giang Nam không khỏi lo lắng mà nói.

- Chờ một chút là được rồi, vẫn còn sớm.

Nhạc Thành mỉm cười nói.

U Minh tông và Luyện Dược sư công hội mấy vạn người liên tiếp gào thét, nhân số đã trở nên đông nghịt.

Unknown said...

This was so useful to read and learn from this blog.
primary school web design

Unknown said...

Great and Useful Article.

Online Java Training

Online Java Training from India

Online Java Training

Online Java Training From India

Java Training Institutes in Chennai

Java Training in Chennai

Unknown said...

Very useful post. Thanks for sharing.

html course in chennai

Best Multimedia said...

good course to learn..web design course

IT said...

I have read your blog its very attractive and impressive. I like it your blog.


JavaEE Training in Chennai JavaEE Training in Chennai

Java Training in Chennai Core Java Training in Chennai Core Java Training in Chennai

Java Online Training Java Online Training Core Java 8 Training in Chennai Java 8 Training in Chennai

IT said...

Online JSF Training JSF Training Institutes in Chennai Java Training Institutes Java Training Institutes Struts2 Training Institutes in Chennai Struts2 Training Institutes in Chennai EJB Training Institutes in Chennai EJB Training Institutes in Chennai

Unknown said...

I read your post. Very nice. Thanks for sharing.

web design course in chennai

Unknown said...

شركة تسليك مجاري بالرياض
شركة تسليك مجارى بالرياض
level تسليك المجاري بالرياض
افضل شركة تنظيف بالرياض
تنظيف شقق بالرياض
شركة تنظيف منازل بالرياض
شركة غسيل خزنات بالرياض
افضل شركة مكافحة حشرات بالرياض
رش مبيدات بالرياض
شركة تخزين عفش بالرياض
شركة تنظيف مجالس بالرياض
تنظيف فلل بالرياض
ابى شركة تنظيف بالرياض

Unknown said...

شركه عزل اسطح
شركه عزل مائى
شركه عزل الاسطح
شركه عزل اسطح
شركه عزل مائى
عزل خزانات
شركه عزل خزانات
شركة عازل خزانات بالرياض
شركه عزل مسابح
شركة عزل خزانات
شركه عزل بالرياض
عزل فوم
شركة عزل فوم
شركة عزل فوم بالرياض
شركة عزل الفوم
كشف تسربات المياه
تسربات المياه
شركة تسربات بالرياض
شركه كشف تسربات بالرياض
شركة رش مبيدات
شركة رش مبيدات بالرياض
رش مبيدات
رش مبيدات بالرياض

for ict 99 said...

Java Online Training Java Online Training Java Online Training Java Online Training Java Online Training Java Online Training

Hibernate Online Training Hibernate Online Training Spring Online Training Spring Online Training Spring Batch Training Online Spring Batch Training Online

Unknown said...

Excellant Article...Really Helpful....
SEO Experts in Bangalore
Top SEO Company in Bangalore
low cost seo packages

Unknown said...


Nice article . Thank you for this beautiful content, Keep it up. Techavera is the best Institute in Noida for all these main Courses below:-
Python training in noida
SAP HANA Training in Noida.
Angular JS Training in Noida.
PLC SCADA Training in Noida.
Embedded Systems training in noida
Tally ERP 9 Training Institute in Noida.
java training center in noida


Visit us For Quality Learning.Thank you

Government Jobs said...

Thanks for sharing this unique information with us. Your post is really awesome. Your blog is really helpful for me..
Top college in Jaipur|law college|law college in Jaipur|Best law college in Jaipur

Government Jobs said...

Hey Your site is awesome and full of information. I have read you posts they are so informative. Keep Posting wonderful content.
Ani international provide the security solutions for all kind of secruity system and other equipment.
Home security system in jaipur
Wireless Home Security System in jaipur
Realtime attendance machine in jaipur
CCTV Camera dealer in jaipur
Hikvision DVR in jaipur at Rajasthan
security system solutions in jaipur
website design in jaipur
website development company in jaipur
seo company in jaipur

Government Jobs said...

Thanks for sharing this unique information with us. Your post is really awesome. Your blog is really helpful for me..
organic oil
organic oil in jaipur
organic cold pressed oils
ayurvedic oil store in jaipur

divi said...

thanks for your information really good and very nice web design company in velachery

The India said...

we have provide the best ppc service.
ppc company in gurgaon
website designing company in Gurgaon
PPC company in Noida
seo company in gurgaon
PPC company in Mumbai
PPC company in Chandigarh
Digital Marketing Company

The India said...

Rice Bags Manufacturers
Pouch Manufacturers
wall putty bag manufacturers
fertilizer bag manufacturers
seed bag manufacturers
gusseted bag manufacturers
bopp laminated bags manufacturer
Lyrics with music

benelli m4 for sale said...

Exotic cart is a well known prefilled THC oil cartridge, and stoners from the west to east drift use them. ... Our cartscontain premium lab tried THC Oil which these days, is hard to find. Our pre-filled cannabis cartridges are ideal for vaping Maryjane in a hurry.
mario carts
exotic carts
dankwoods for sale
brass knuckles vape
buy carts
mario carts flavors
buy pink rutz
mario carts online
mario cartridges
mario carts for sale
stiiizy pod
space monkey meds
organic smart carts
mario carts thc
smart carts
buy blue dream online
buy mario carts vape
buy runtz
buy white runtz
710 kingpin vapes
moonrock clear carts
kingpen gelato
buy Ak-47
buy skywalker og online
runtz
rove carts
cereal cart
buy weed
dankvapes
space monkey meds
dank vapes
organic smart carts
mario carts thc
smart carts
buy mario carts cartridges
710 kingpin vapes
buy afghan haze
buy og kush
buy white runtz

Marry07 said...

You can join the free orientation at Workday training institutes in Bangalore and they located at Workday training institutes in delhi. It is highly recommendable for you to enroll at Workday training institutes in UK and you can have a great market for jobs in USA so join this wonderful Workday training institutes in USA and in India this Workday training institutes in Noida is really best institute.

ramesh said...

I simply want to mention I am just all new to blogging and site-building and truly loved you’re web page. Almost certainly I’m planning to bookmark your site . You really have outstanding stories. Many thanks for revealing your webpage.…

Azure Training in Chennai

Azure Training in Bangalore

Azure Training in Hyderabad

Azure Training in Pune

Azure Training | microsoft azure certification | Azure Online Training Course

Azure Online Training

Mohd Sharique said...

This was nice and amazing and the given contents were very useful and the precision has given here is good.

Online Training for Big Data
best Apache Spark online course

Technogeekscs said...

Thanks for Sharing a Very Informative Post & I read Your Article & I must say that is very helpful post for us.
Data Science Course in Pune
Python Classes in Pune
AWS Training in Pune
Best RPA Training in Pune

sierra zoe said...

Hi, every day I visit a number of blog sites but I'm very happy to read your post Thanks for sharing the informative blog post about visual effects training.

varchasasunny said...

Thank you for this article because it’s really informative, I love reading your article and I hope that I will read some more about this stuff, it’s really informative and very entertaining. Thanks a lot and have a great day. >.Looking for best visual effects training in Hyderabad? For courses in VFX film making, Digital advertising, Web Design, Graphic Design, 2D & 3D Animation & Visual Effects visit Arenadilshuknagar.

gracemila said...

Thanks for sharing this amazing piece of content and this post helps me a lot and I really like it. Its amazing thing. Looking for best vfx training in Hyderabad? For courses in VFX film making, Digital advertising, Web Design, Graphic Design, 2D & 3D Animation & Visual Effects visit Maacdilsukhnagar.