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).
|
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):
|
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 !!!
|