cancel
Showing results for 
Search instead for 
Did you mean: 

Removing empty tags from xml schema

shaji_chandran
Participant
0 Kudos

Hi,

I would like to know how to remove the empty tag of an xml schema in the expression editor according to a condition. I will brief my requirement. I have a local xml variable as MainSchema in my transaction. I fetch the data using a sql query and populate this xml schema (MainSchema). In case the query is not returning the data for an xml tag, I want to remove that xml tag from the schema. Currently it is displaying empty tags in the schema.

Can any one help me on this?

Thanks

Shaji

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

After fecthing data using SQL query, how are you populating XML ?

If you are using repeater for filling SQL data , You can use XPath for repeater to exlcude blank/null values.

In this way you can avoide empty tags.

If this doesn't suit your need then plz explain in requirement details

Regards,

Shalaka

shaji_chandran
Participant
0 Kudos

Hi

I am using a repeater to populate the data in xml schema. I know I can put an if condition to check the empty value. In case value is empty i should not assign the empty value to tag. But my tag is still exists there in the schema. I would like to remove the empty tag from the schema

Thanks

Shaji

agentry_src
Active Contributor
0 Kudos

Shaji,

See Michael Otto's response.

Using an assignment block, you can remove the xml node by selecting the node you wish to remove and in the middle of the link editor select Link Type - Remove XML, then hit update. A new link will be created and the Expression will be "<<REMOVE>>".

Test it to see how to integrate it into your situation.

Regards,

Mike

Former Member
0 Kudos

Hi Shaji,

for removing tags (nodes) from xml, you can use the assignment action. Use the Link Type "RemoveXml" for this as described in the [Link Type|http://help.sap.com/saphelp_mii121/helpdata/en/43/e80b59ad40719ae10000000a1553f6/frameset.htm].

Hope this helps.

Michael

shaji_chandran
Participant
0 Kudos

Hi,

But how do I put the if condition to check whether the value is is empty or not?

Thanks

shaji

Former Member
0 Kudos

You can use the Conditional action to check if a value is empty, and use the true branch of the action with an assignment action and Link Type RemoveXML.

Is this what you are looking for, or do you problems with the Link Type "RemoveXML"?

Michael

Edited by: Michael Otto on Sep 21, 2010 12:45 PM

shaji_chandran
Participant
0 Kudos

Hi Michel,

Thanks for your response. In this case for each tag I have to add one Conditional action block which make my transaction very big. If I have to check 25 tags then there will be 25 Conditional action block. I am looking some otherway to fix the problem.

Something like using stringif() I check the empty value and remove that particular tag from schema.

Please let me know if you have any thoughts

Thanks

Shaji

Former Member
0 Kudos

Hi Shaji,

if you really have to remove many nodes from the XML, the Conditional / RemoveXML proposal is not really useful. The stringif will not work as desired in this case. XPath may do the trick, but not without some try and error effort.

Have you thought about using a XSL transformation to solve the request? MII offers a [XSL Transformation action|http://help.sap.com/saphelp_mii121/helpdata/en/43/e80b59ad40719ae10000000a1553f6/frameset.htm]. You could copy the input XML to output and omit the empty nodes.

Michael

sidnooradarsh
Contributor
0 Kudos

Why not give a try to create a document dynamically based on your sql resultset

Take a blank document

Add Rowset

Add Columns

Add Row/s

Add dataitem

Hope this helps!!

Regards,

Adarsh

Former Member
0 Kudos

Hi Adarsh,

yes, you point in the same direction as me. Instead of trying to remove nodes, build the XML from scratch. Avoid adding empty nodes in it, just add the nodes you need.

Michael

shaji_chandran
Participant
0 Kudos

Thanks Michel.

I acheived it using XSL Transformation action block

Thanks again

Shaji