Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
hp1
Contributor
Contributor

Start and end tag (empty) instead of self closing tags in xml

Hi

Is there any way to have empty tags i.e <tag_name></tag_name> instead of self closing tags i.e <tag_name/> while using tAdvancedOutputFileXml component.

I am writing to an

tAdvancedOutputFileXml in first subjob with settings as create empty element , create attributes eevm if null and create attributes even if it's unmapped as checked.

2nd, 3rd and 4th subjob append to the xml created in first subjob.

Problem I am facing is when I execute first subjob it creates and empty tag as expected.

i.e <tag_name></tag_name>

However when executed as a whole it converts the empty tag to a self closing tag.

i.e <tag_name/>

​Any way we can keep the empty tags as is instead of self closing tags?

Labels (3)
6 Replies
Anonymous
Not applicable

Can you show us a screenshot of your job so that we can see what other components you are using? I suspect that the conversion is taking place when you are appending to the xml in subjobs 2, 3 and 4.

hp1
Contributor
Contributor
Author

That is exactly what is happening @Richard Hall​ .

Unfortunately I will not able to provide a screenshot but can let know th design. Hope it helps

 

Subjob1:

flat file -> tMap -> tAdvancedFileoutputXML

(Create empty element, create attribute even if null and create attribute even if unmapped - All are enabled)

 

Subjob2:

flat file -> tMap -> tAdvancedFileoutputXML(Append)

(Create empty element, create attribute even if null and create attribute even if unmapped - All are enabled)

 

Subjob3:

flat file -> tMap -> tAdvancedFileoutputXML(Append)

(Create empty element, create attribute even if null and create attribute even if unmapped - All are enabled)

 

Now when executed Subjob1 in isolation it creates the tags as

<Name></Name>

<Id></Id>

 

However when I enable the Subjob2 the tags now become selfclosing tags

<Name />

<Id />

 

Is there any way to preserve the expanded empty tags through configuration is my ask.

Without adding a code specifically to replace the self closing tags with expanded tags after the entire XML is created

tnewbie
Creator II
Creator II

As self enclosing tags are treated as standard substitute for null values, I am not sure if there is a way to explicitly depict a opening and closing tag for null values. The easiest way that comes to my mind is, do a find and replace of self enclosing tag, look for "/>", once found traverse back till you find "<" and generate the open and closing tags.

hp1
Contributor
Contributor
Author

Well I have assigned a dummy static value if it's empty and added a post process to replace the static value with a blank. But wanted to do it through configuration instead of adding a code

tnewbie
Creator II
Creator II

It depends on the Domain that you are working with. In certain data exchanges especially under Healthcare Domain we will not be allowed to meddle with incoming data what so ever. I am not sure if substituting a constant and then replacing it, is permitted. If it does, good for you 🙂

Anonymous
Not applicable

Sorry about the delay in getting back to you. I have been a little busy and forgot that I had asked for more information. I think your suggestion is the way I would go. Technically there is no difference (according to the XML specification) between....

 

<tag></tag>

 

....and....

 

<tag/>

 

But I know that some parsers don't work that way.

 

I think I would add your unique static value and carry out a find and replace.