Question
· Jul 15, 2020

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

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

Discussion (4)2
Log in or sign up to continue