0

I have a query here.

This Query is similar to optional JAXB xml attribute while marshalling

I want to hide some attribute while marshalling in JAXB

There would be cases, when I just want to have a variable in the file, but I don't want that to be displayed in the XML output.

Is there a way to do that ?

For example in the below case, I don't want to show "deviceStatus" attribute. But I will just use it internally in my code.

<DeletionResult>

  <device-result>
        <device id="100" deviceStatus="online" completed="true"/>
        <device id="101" deviceStatus="online" completed="true"/>
        <device id="102" deviceStatus="offline" completed="true"/>       
  </device-result>

</DeletionResult>

Yes agreed, setting it to Null will not show it in the XML output. But in my case it is costly operation, because I need to iterate all the devices object and need to set deviceStatus to null. (There could be thousands of devices or even more)

Please let me know if there is any other option to achieve this ? instead of null.

Community
  • 1
  • 1

1 Answers1

1

Use annotation @XmlTransient for the attribute you want to hide.