Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Custom formatting of XML export

    I export a list of elements based in example:
    http://www.smartclient.com/smartgwtee/showcase/#custom_export

    and I get the following output in XML:
    Code:
    <List>
      <Object>
        <Impact>data interrupted</Impact>
        <Subject>eclipse-season</Subject>
        <Type>Planned Maintenance</Type>
        <End Time>2014-09-29T22:00:00</End Time>
        <Satellites>MET-7</Satellites>
      </Object>
      <Object>
        <Impact>data interrupted</Impact>
        <Subject>eclipse-season</Subject>
        <Type>Planned Maintenance</Type>
        <End Time>2014-09-29T22:00:00</End Time>
        <Satellites>MET-7</Satellites>
      </Object>
    </List>
    However, I would like to get something more like:

    Code:
    <announcements>
      <announcement Impact="data interrupted" Subject="eclipse-season" Type="Planned Maintenance">
        <End Time>2014-09-29T22:00:00</End Time>
        <Satellites>MET-7</Satellites>
      </announcement>
      <announcement Impact="data interrupted" Subject="eclipse-season" Type="Planned Maintenance">
        <End Time>2014-09-29T22:00:00</End Time>
        <Satellites>MET-7</Satellites>
      </announcement>
    </announcement>
    That is, how do I:
    1) change "List" to a value defined by me: "announcements"
    2) change "Object" to a value defined by me: "announcement"
    3) change elements into attributes, from instance Impact. This would be the equivalent as using annotations @XmlAttribute, @XmlElement

    Is 3) possible at all? Or should I look into another way to implement the XML formatting different from the example above.

    Thanks in advance,

    #2
    You should just directly output the XML you want to the servlet OutputStream. See the next sample in that folder for sample code: "Custom Export (Custom Response)"

    Comment

    Working...
    X