Author |
Message
|
kwelch |
Posted: Fri Oct 31, 2003 8:12 am Post subject: how to get rid of empty tags |
|
|
 Master
Joined: 16 May 2001 Posts: 255
|
Hi,
I am formatting an XML output message from legacy cobol. When fields come in with spaces or low-values I don't want to create the empty tags or the shortcut. This seems to be working fine as long as those tags are under aggregates(not sure if this is the correct term, parent?) that have at least one field filled in, but when I hit an entire aggregate where all the fields are blank, I get the shortcut. Is there a way to avoid this? Here is a sample of the xml. The fields in red are the ones I would like not to show up. For example there are fields under <PolicyNumber> that are not showing up because they are spaces but there is one field under that aggregate. For <Prior_Policy_Number> all the incoming fields are space.
Hopefully this explains what I am trying to acoomplish?
<?xml version="1.0" encoding="UTF-8" ?>
- <PINSDataReply>
- <PolicyInfo>
- <PolicyNumber>
<Reg_Off_Code>02</Reg_Off_Code>
</PolicyNumber>
<Name_Insured>THERMA SCAN</Name_Insured>
<Insured_Street>P.O. BOX 121</Insured_Street>
<Insured_City>ELLINGTON</Insured_City>
<Insured_State>CT</Insured_State>
<Zip>06029</Zip>
<Pol_Eff_Date>2001/07/21</Pol_Eff_Date>
<Pol_Exp_Date>2002/07/21</Pol_Exp_Date>
<Policy_Status>S</Policy_Status>
<Prior_Policy_Num />
</PolicyInfo>
- <AgencyInfo>
<Agency_Code>024097</Agency_Code>
</AgencyInfo>
<Error_Messages />
</PINSDataReply> |
|
Back to top |
|
 |
Michael Dag |
Posted: Fri Oct 31, 2003 10:00 am Post subject: |
|
|
 Jedi Knight
Joined: 13 Jun 2002 Posts: 2607 Location: The Netherlands (Amsterdam)
|
But what does it matter? other then the cosmetic fact that you want to get rid of them?
Michael |
|
Back to top |
|
 |
kwelch |
Posted: Fri Oct 31, 2003 10:05 am Post subject: |
|
|
 Master
Joined: 16 May 2001 Posts: 255
|
Mike,
We don't want to make the message any bigger than it has to be. This is a small example to illustrate the problem but we have other projects that use ACORD XML and there are tons of fields that will not be filled in. Why carry the extra bytes if you don't have to?
Karen |
|
Back to top |
|
 |
Michael Dag |
Posted: Fri Oct 31, 2003 10:10 am Post subject: |
|
|
 Jedi Knight
Joined: 13 Jun 2002 Posts: 2607 Location: The Netherlands (Amsterdam)
|
Isn't that an oxymoron when using XML?
I get your point.
Michael
The solution I think is to NULL the tags and then they will disappear, now find a way to detect the empty content... |
|
Back to top |
|
 |
kwelch |
Posted: Fri Oct 31, 2003 10:46 am Post subject: |
|
|
 Master
Joined: 16 May 2001 Posts: 255
|
Hi Michael,
Yeah I get your point also!
I was trying to incorporate a suggestion given to me to use the NULLIF statement. I was coding the following:
SET OutputRoot.XML.PINSDataReply.PolicyInfo.Prior_Policy_Num.Prior_Pol_Num = NULLIF(TRIM("InputBody"."XCS08_POLICY_INFO"."XCS08_POLICY_INFO_D"."XCS08_PRIOR_POLICY_NUMBER"."XCS08_PRIOR_POL_NUM"), ' ');
By coding the below I resolved the empty tag issue:
IF TRIM("InputBody"."XCS08_POLICY_INFO"."XCS08_POLICY_INFO_D"."XCS08_PRIOR_POLICY_NUMBER"."XCS08_PRIOR_POL_NUM") <> ' ' THEN
SET OutputRoot.XML.PINSDataReply.PolicyInfo.Prior_Policy_Num.Prior_Pol_Num =
TRIM("InputBody"."XCS08_POLICY_INFO"."XCS08_POLICY_INFO_D"."XCS08_PRIOR_POLICY_NUMBER"."XCS08_PRIOR_POL_NUM");
END IF;
I guess by setting it to NULL you are somehow still referencing that higher tag? This way no reference is made to Prior_Policy_Num so I don't get the <Prior_Policy_Num/>.
Thanks for your responses.
Karen |
|
Back to top |
|
 |
|