cancel
Showing results for 
Search instead for 
Did you mean: 

Handling Attributes in xpath expressions in CPI HCI

TomR
Explorer
0 Kudos

Having a problem with trying to use an attribute in the condition filter - my example data below we have data coming in using Attributes:

<Logs>

<IMPORTACION ImportacionInicio="2019-11-06 10:29:45" ImportacionFin="2019-11-06 10:29:45">

<REGISTRO Action="HIR" Linea="1" LineaStatus="3" LineaStatusDesc="Hay Errores">

<LOGS>

<LOG Linea="1" Orden="1" Tipo="1" TipoDesc="Informativo" Error="50011" Descrip="El Movimiento de Alta fue actualizado correctamente en esa fecha"/>

</LOGS>

</REGISTRO>

<REGISTRO Action="BC" Linea="3" LineaStatus="3" LineaStatusDesc="Hay Errores">

<LOGS>

<LOG Linea="2" Orden="7" Tipo="3" TipoDesc="Error" Error="50007" Descrip="La Persona ya tiene movimientos de ese tipo en fechas posteriores"/>

</LOGS>

</REGISTRO>

</IMPORTACION>

</Logs>

We want to filter out the information records by the attribute TipoDesc="Informativo" to eliminate the information records and only show the records with actual errors

I am using the the XPath expression /Logs/IMPORTACION/REGISTRO[LOGS@TipoDesc!='Informativo'] to filter the records - but getting an error:

Error Details org.apache.camel.CamelExchangeException: Sequential processing failed for number 0. Exchange[ID-vsa6834258-45242-1573296610082-334-16]. Caused by: [org.apache.camel.CamelExchangeException - Parallel processing failed for number 1. Exchange[ID-vsa6834258-45242-1573296610082-334-19]. Caused by: [org.apache.camel.builder.xml.InvalidXPathExpression - Invalid xpath: /Logs/IMPORTACION/REGISTRO[LOGS@TipoDesc!='Informativo']. Reason: javax.xml.xpath.XPathExpressionException: net.sf.saxon.trans.XPathException: expected "]", found "@"]], cause: net.sf.saxon.trans.XPathException: expected "]", found "@" The @ sign is a standard XPath expression for attributes - however I get the impression that SAP HCI does not handle XPath attributes. Is that true?
View Entire Topic
MortenWittrock
Active Contributor
0 Kudos

Hi Tom

You're nearly there! This adjustment of your XPath expression will work:

/Logs/IMPORTACION/REGISTRO[LOGS/LOG/@TipoDesc != 'Informativo']

Assuming that there's only one LOGS child of REGISTRO and one LOG child of LOGS. This seems to be the case, though, from your example.

Regards,

Morten

TomR
Explorer

Hey thanks, that worked fine