cancel
Showing results for 
Search instead for 
Did you mean: 

XML data fiter in SAP HCI

hsonnenahalli
Contributor
0 Kudos

Dear Experts-

I have an issue with extracting certain data and send the data to XSLT mapping. I am doing a real time query to API using a Survey Key to fetch the results. I am generating multiple files which has following 2 of data in separate files..

Data 1 which works fine with my XSLT mapping as it has results for the survey key.

<?xml version='1.0' encoding='UTF-8'?>

<Root>

<Element>

<SK>319010</SK>

</Element>

<Element>

<meta/>

<data>

<ts>2017-12-01T14:12:58.000-08:00</ts>

<r>0</r>

</data>

<data>

<ts>2017-12-01T14:12:59.000-08:00</ts>

<r>0</r>

</data>

</Element>

</Root>

Data 2 which my XSLT map fails because no data for particular survey key.

<?xml version='1.0' encoding='UTF-8'?>

<Root>

<Element> <SK>216621</SK>

</Element> <Element>

<meta/>

<data/>

</Element> </Root>


I need to filter the data before sending it to map in a way that I will send only survey key data which has results. I am trying to use Filter and Router in HCI but am not successful. This is really urgent as have golive in 2 days. If you can help to get this through it would be much appreciated.

Regards

HS

Accepted Solutions (1)

Accepted Solutions (1)

hsonnenahalli
Contributor
0 Kudos

The issue got resolve using router condition. Having below XPATH expression.

count(/Root/Element/data/ts) != 0

Thanks

HS

Answers (1)

Answers (1)

apu_das2
Active Contributor
0 Kudos

Hi,

Use filter with below XPath -

/Root/Element/data[string-length(ts)>0]

Thanks,

Apu

hsonnenahalli
Contributor
0 Kudos

Hi Apu-

Appreciate your quick response. When I use XPath which you have mentioned am getting the below results.

<data> <ts>2018-09-07T08:27:06.000-07:00</ts>

<r>0</r> </data>

I need to get following format. which means that for survey key which has results need to extract all the data. Please let me know.

<Root>

<Element>

<SK>319010</SK>

</Element>

<Element>

<meta/>

<data>

<ts>2017-12-01T14:12:58.000-08:00</ts>

<r>0</r> </data> <data>

<ts>2017-12-01T14:12:59.000-08:00</ts>

<r>0</r> </data>

</Element>

</Root>


Regards

HS

apu_das2
Active Contributor
0 Kudos

First of all, use Nodelist instead of node to get the value of both ts node.

Secondly, using filter pallet you can't get the output you are expecting as SK node and ts node are coming under two separate Element node.

So, you can store the SK value in header and then use the filter to get data then in your xslt mapping you can call the header value to map with your target structure.

Thanks,

Apu

hsonnenahalli
Contributor
0 Kudos

Thanks for the reply. I am not sure if am understanding the below solution.

So, you can store the SK value in header and then use the filter to get data then in your xslt mapping you can call the header value to map with your target structure.

I am using map force to do my XSLT mapping. I am passing the header dynamically in the API and storing the same in the content modifier in the body and then create an XML file structure and generate multiple files. My next steps is XSLT mapping. Please can you explain in more detail.

Much appreciated.

Thanks

HS

hsonnenahalli
Contributor
0 Kudos

Sorry just pasted one data set. I am using Nodelist.