There is a ConstantTransformer that can be used with an XMLTransformationMapping that may solve your requirement (you will need to add this transformer through an amendment method if using the MW). There is also a document preservation feature see, XMLDescriptor.setShouldPreserveDocument().
amphoras wrote:
Hi,
The situation I have is that there are some constant values that I want to appear in my XML output document (like application=Foo). I don't want this value to be affected by unmarshalling. How does one map this kind of "constant"?
After playing around with EclipseLink, it looks like even though this value is supposed to be a constant, I need to create a variable for it in my domain object in order to create a mapping to the proper XPath. But then what should I do? I don't want this variable's value to change by unmarshalling. I can write an afterLoad method to reset the variable back to its original value. That way when I marshall the object, the correct value will be output in the XML. But is there a better way to do this? Does EclipseLink support one-way mappings or marshalling constants?
Thanks!
--Polly