cancel
Showing results for 
Search instead for 
Did you mean: 

How to use XPath with Default Namespace in CPI

jasonwilliams
Explorer

Hi,

I'm trying to use the Content Modifier to retrieve some fields from a SuccessFactors oData standard XML payload. The Atom XML has the following root node with namespaces defined:

<entry xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xml:base="https://api10preview.sapsf.com:443/odata/v2/">

I have added the namespaces to the CPI iFlow> Runtime Configuration> Namespace Mapping as:

xmlns=http://www.w3.org/2005/Atom;xmlns:d=http://schemas.microsoft.com/ado/2007/08/dataservices;xmlns:m=http://schemas.microsoft.com/ado/2007/08/dataservices/metadata

However CPI complains that I don't have a prefix for the default namespace with "Enter a valid collaboration namespace eg. xmlns:test=http://test.com/test". When I remove the default namespace or add an alias/prefix to the default CPI is happy, but at runtime the XPath isn't evaluated successfully and I get no data returned.

There are ways around the issue (eg. remove namespaces from the XML, remove just the default namespace from the XML, tried wild-carding the default namespace elements in the XPath but that didn't pass validation) however I don't believe I should have to and assume I just need to know a 'default' namespace prefix alias (or some similar small tweak).

How do I specify a default namespace along with explicit aliased namespaces?

Thanks,

Jason

Accepted Solutions (0)

Answers (3)

Answers (3)

jasonwilliams
Explorer

I've found an acceptable workaround:

Basically create an alias for the default Namespace and reference that in your XPaths:

eg. xmlns:a=http://www.w3.org/2005/Atom

Then in the XPath use the alias prefix for the default namespace eg. /a:entry/a:content/m:properties/d:firstName

Its not ideal, but a simple workaround. Still interested to know if there is a way to use the default namespace though.

former_member666312
Active Participant
0 Kudos

Hi,

you are right , if you have many fields to take xpaths and complex namespaces are there then it might help, otherwise, our approach is fine. as an example,i taught of it.

Thanks,

Vijay

former_member666312
Active Participant
0 Kudos

Hi ,

One way i think is , if you have a standard structure then do a mapping with source as EDMX and Receiver with the expected XSD. Then it will produce simple xml from the atom-xml.

Thanks and Regards,

Vijay.

jasonwilliams
Explorer

Hi Vijay,

Thanks for the response. As I mentioned in my question, I realise that there are several possible workarounds which involve transforming the incoming payload. However I don't believe you should need to do that to access basic Xpath functionality on XML produced by a standard SAP system (or any other internet standard system for that matter).

I should be able to create my Xpath in Oxygen based on the SuccessFactors oData payload (which I did) and use the resultant XPath without having to transform the payload or introduce an artificial namespace alias/prefix.

Thanks again for the response.