0

I would like to know if there is a convenient way to customize the output xml of MOXy? Specifically, in some classes I would like to print the attributes in separate lines. For example:

  <someClass
     attr1="val1"
     attr2="val2"
     attr3="val3"> ...
  </someClass>

I wouldn't like to write fully custom marshaller, but rather an adapter if it is possible.

bdoughan
  • 147,609
  • 23
  • 300
  • 400

1 Answers1

1

You can set the Marshaller.JAXB_FORMATTED_OUTPUT property on the Marshaller to have the output pretty printed if you are using EclipseLink MOXy or another JAXB (JSR-222) implementation.

Marshaller marshaller = jc.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(foo, System.out);

Currently we don't offer the ability to output attributes on their own line. If you are interested in this type of feature, then please enter an enhancement request using the link below against the MOXy component.

bdoughan
  • 147,609
  • 23
  • 300
  • 400