Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
DaveTaylor
Contributor III
Contributor III

Xml of Document type, returning from tHMap; best practice to remove empty tags?

tXmlMap has a checkbox item to remove empty tags; but tHMap (returnning from Mapper) doesn't seem to have this option.

What is the best practice case on a returned Document type from the tHMap, to remove empty tags?

Thanks

Labels (3)
6 Replies
Anonymous
Not applicable

Hello,

We have redirected your issue to our data mapper expert and then come back to you as soon as possible.

Thank for your time.

Best regards

Sabrina

Haitao
Creator
Creator

Hi,

 

You can set the structure's element to optional in TDM0683p000009LrG3.png

 

 

 

 

 

 

 

If you map the structure like 
0683p000009LrV8.png
with the input

 

<?xml version="1.0" ?>
<Root>
  <b>
    <c>foo</c>
  </b>
  <b>
    <d>bar</d>
  </b>
</Root>

then the output will be also

<?xml version="1.0" ?>
<Root>
  <b>
    <c>foo</c>
  </b>
  <b>
    <d>bar</d>
  </b>
</Root>

 

DaveTaylor
Contributor III
Contributor III
Author

Thanks for the reply; I do see in the structure; when [Read Only] is selected; the Basic section which contains the option of Mandatory (default).
However, I do not see a way to edit this to be Optional (Nullable) on the basic section.

When I switch from [Read Only] to [Editiable] I do not see any selectable choices reflecting 'Mandatory' anymore; or anywhere to pick 'Optional'.
I do see a nullable checkbox; but that doesn't switch it from Mandatory to Optional.

Question 1) so what am I missing to edit this property to be optional?

 

 

Also 
A second question if you don't mind.
When I load a pre-defined xml structure; if a tag has attributes; then structure tree has Tag/Attribute/attribute tag in the tree format.
However, if I manually add a new tag; set it to be of type Xml Attribute; it does show with the Attribute icon; and shows to be an Attribute; but the word 'Attribute' doesn't appear in the tree structure between it and the root node.  Is this ok?  Seems odd.  Is this ok?

0683p000009LrUc.png

DaveTaylor
Contributor III
Contributor III
Author

I found the answer to the Mandatory vs Optional; Setting the Occurs to 0 1 did the trick on a non-looping tag.

Still unsure why Attributes is missing from the tree on a added tag/attribute; and if it matters. (screencap above)

Haitao
Creator
Creator

Hi,

 

When an element's 'Visible Group' is unselected, then it will be disappeared

DaveTaylor
Contributor III
Contributor III
Author

What ultimately allowed me to controller mapper elements and attributes; and designate that they would not show if they do not have data; was to set the Occurs Min/Max "Min" value to 0 for any element or attribute; that could have missing data; and if the data is missing; you want to suppress the tag.

Doing the Visible Group toggle didn't help because while it did remove the element completely; if there was data mapped to that element; it was placed in the xml at that point; without a holding element to hold it; and the xml thereafter failed validation.

 

Using the Occurs Min = 0 is the trick.

Thanks all for your replies.