Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to generate a XML binding file from a class using MOXy?

Tags:

jaxb

moxy

I'm would like to use MOXy to marshal / unmarshal object from existing classes.

I would like to know if there is a mean to generate XML binding files (cause I don't want to use annotations) from my classes.

Or do we have to do it all with our little hands :) ?

like image 259
avi.elkharrat Avatar asked Feb 02 '26 21:02

avi.elkharrat


1 Answers

By default JAXB/MOXy doesn't require any metadata to be specified (see: http://blog.bdoughan.com/2012/07/jaxb-no-annotations-required.html). You only need to specify the metadata where you want to override the default behaviour.

I'm guessing your real question is what is the easiest way to create the MOXy external mapping document. I do the following with Eclipse, there are probably similar steps for your favourite IDE:

  1. Get the XML Schema for MOXy's mapping document

    <EclipseLink_Home>/xsds/eclipselink_oxm_2_5.xsd
    
  2. Register the XML Schema with your IDE

    1. Eclipse | Preferences | XML | XML Catalog | Add
  3. Create and XML document in the IDE and specify the following as the root element.

    <xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm"/>
    
  4. Use the auto-complete functionality offered by your IDE to construct the XML document.

like image 192
bdoughan Avatar answered Feb 04 '26 16:02

bdoughan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!