IMPORTANT:
this is not a Support Forum! Experienced users might answer from time to time questions posted here. If you need a professional and reliable answer, or if you want to report a bug, please contact Altova Support instead.

Supress empty nodes Options · View
rzsolesz
Posted: Tuesday, November 17, 2020 7:10:25 AM
Rank: Newbie

Joined: 11/16/2020
Posts: 2
I am newbie in Altova Mapforce, and I would appreciate if I could get some help. I need to make an xml from excel sheet.
The output contains <Product/> element in case there aren't any child nodes.
Is there a way to remove or supress all the empty tags that are generated ?

<WAREHOUSE xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file://tsclient/U/XML/product2.xsd">
<ROOM>A</ROOM>
<Product>
<PRODUCT_ID>1</PRODUCT_ID>
<PRODUCT_NAME>first</PRODUCT_NAME>
</Product>
<Product>
<PRODUCT_ID>11</PRODUCT_ID>
<PRODUCT_NAME>first</PRODUCT_NAME>
</Product>
<ROOM>B</ROOM>
<Product>
<PRODUCT_ID>2</PRODUCT_ID>
<PRODUCT_NAME>second</PRODUCT_NAME>
</Product>
<Product/>
<ROOM>C</ROOM>
<Product/>
<Product/>

</WAREHOUSE>

File Attachment(s):
product2.mfd (4kb) downloaded 54 time(s).
product2.csv (1kb) downloaded 54 time(s).
product2.xsd (1kb) downloaded 52 time(s).


K101
Posted: Wednesday, November 18, 2020 9:28:18 AM
Rank: Advanced Member

Joined: 2/27/2009
Posts: 565
First, uncheck the "Treat empty rows as absent" option in the input component properties.

Then, connect your Rows to each of the two Product items. Insert a filter, then use empty to test for the id and name fields to be, well, empty.

Use a logical-and to combine those two, and connect the logical-and to the filter's bool input.

Finally, move the filter's connection from on-true to on-false.

Also, your schema doesn't look right to me. You probably want one WAREHOUSE element for each row. Since WAREHOUSE is your root, you will only get one. Add a WAREHOUSES root element so it can contain multiple WAREHOUSE elements.

Also, for each WAREHOUSE, the Product element should be allowed to occur between 0 and 2 times only.

All this is demonstrated in the attached examples. Note also how we converted the empty/logical-and/filter structure for the second Product into a User-Defined Function called, "cancel-empties".

File Attachment(s):
example.zip (3kb) downloaded 77 time(s).

K101 attached the following image(s):
Example.png
UDF.png

rzsolesz
Posted: Wednesday, November 18, 2020 12:44:15 PM
Rank: Newbie

Joined: 11/16/2020
Posts: 2
I really appreciate your help. Honestly, the real source xsd much more complicated than the sample xsd, hence I have to set the function for all the related sequence, but the approaching works. Thanks a lot !!!
Users browsing this topic
guest

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Use of the Altova User Forum(s) is governed by the Altova Terms of Use.