How to Create an XML from Serial Classes with populated segments leaving out empty elements

Primary tabs

Lets say I have a serial Class A ,Serial Class B,Serial C and Persistent Class Ens.Request

Class SerialA Extends (%SerialObject, %XML.Adaptor) [ ProcedureBlock ]
{
      Property SerialB as SerialB  
     Property SerialC as SerialC
}
     Class SerialB Extends (%SerialObject, %XML.Adaptor) [ ProcedureBlock ]
{
    Property SerialB as %String
}

Class SerialC Extends (%SerialObject, %XML.Adaptor) [ ProcedureBlock ]
{
     Property SerialC as %String
}

Class PersistantClass Extends Ens.Request
{
     Property Record as SerialA
}

the produced xml looks like this  :

<Record>
<SerialA>
      <SerialB></SerialB>
      <SerialC></SerialC>
     </SerialA>
</Record>

I would Like it to look like this:

<Record>
<SerialA>
  <SerialB></serialB>
 </SerialA>
</Record>

Is there way to control this as setting IGNORE NULLS does not work either.

Having had your responses I had a look further and noticed that if I had my classes as persistent I can populate my segments as I please but when these are Serial the problem arise of not being able to produce the populated XML but rather the whole structure even if IGNORENULLS is set.Since messages passed here will form a Ensemble message there is no need to make these persistent.So having said that is there a way to go around it

Replies

Hi Thembelani

If I understood, you don't want to project the SerialC. If is this, remove the %XML.Adaptor from the Extends class list.

Class SerialA Extends (%SerialObject, %XML.Adaptor) [ ProcedureBlock ]
{
      Property SerialB as SerialB;
     Property SerialC as SerialC(XMLPROJECTION = "NONE");
}