Question
· Jul 4, 2023

How to remove empty XLM-tags in transformation using EnsLib.EDI.XM?

Hello!

In a transformation (DTL) I create an XML and pass it to an EnsLib.EDI.XML.Operation.FileOperation.

The receiver does not accept an empty tag (eg <Analysis/>) that is created automatically
if the tag has no values ​​in underlying tags. I have tried with action='remove' in transformation
and other things but it only clears the content.

I need to remove the tag completely. Appreciate if anyone has a tip?

Sincerely, Michael Lundberg

Product version: IRIS 2021.1
Discussion (6)3
Log in or sign up to continue

Hello again

Previous experience that I have (with health connect), underlying tags can be mandatory to a tag that is optional. So only if the parent-tag is included, the children that are mandatory must be included.

I tried with:
<xs:element name="Analysis" maxOccurs="unbounded" minOccurs="0">
and it could pass the transformation but still had no effect.

Right now I remove the tag afterwards using objectscript. It does work, but is still a more cumbersome way to solve it. It would be best if it could be removed already in the transformation.

Sincerely, Michael

I dealt with a similar issue and found that if I wrapped the "set action" in an if statement where I would only set the target tag IF the length of the source tag was greater than 1, then it would not send an empty tag. 

Have you tried wrapping that set in an if statement? 

For example in this screenshot below, I take in one XML file and I send it to another XML file with NO IF surrounding the set statements of all of my data tags. 

And that when I test this there are not even any data in my DATA source tag yet everything populates in my DATA Target Tags with null values: 


However, when I wrap all of those same data tag sets in an if statement so that they are set only if an data id is populated like so: 


It will no longer send null tags for the data elements: 


Hopefully the issue is similar and this helps! 

Hi Victoria and thank you for taking the time to reply.

I do something similar today and it gives an empty tag anyway.

The condition is that if a certain tag has no children, none of that tag should be presented-

Example:

<Parent>
      .......
      .......
     <Child>
       ...
     </Child>
<Parent>

Above XML is to be presented.

<Parent>
     .........
</Parent

Above XML should NOT be presented.

I try in the transformation:
If source.Parent.(k1).Child.(1)=""
 <False>
  Do the map
</False>


I first expected a null exception if the Child tag didn't exist but HC seems to be able to handle that.

I also tried changing the condition to your suggestion:

If ..Length(source.Parent.(k1).Child.(1)>1)

<True>
   .......
</True>

But it gave the same result unfortunately.

Sincerely, Michael