cancel
Showing results for 
Search instead for 
Did you mean: 

Split logic in Content modifier HCI/CPI

anurag_sinha3
Participant
0 Kudos

Hi,

I have a requirement where from source some pipe separated value is coming and we have to fetch it .

for e.g. If the value coming as 01|02|03|04|05

then the required value is(Separately ) - 01

02

03

04

05

is it possible to do in content modifier . if so then how o acieve this

or atleast we get "01" first value

MortenWittrock
Active Contributor
0 Kudos

Hi Anurag. When posting new questions, please remember to also follow up on the questions, you already have open. Regards, Morten

Accepted Solutions (0)

Answers (3)

Answers (3)

sanjali07
Participant
0 Kudos

Is this the expression you have?
substring-before{Root/Element/InputParameters "|"}

Note function-call format, it should have round brackets and a comma between params.

substring-before(Root/Element/InputParameters, "|")

Regards

apu_das2
Active Contributor
0 Kudos

If it is a CSV data then you can use CSV to XML converter to get the separated field values in the defined XML nodes. If further modification is required, you can use gsh/message mapping.

anurag_sinha3
Participant
0 Kudos

hi,

it is coming directly in Json format

sanjali07
Participant
0 Kudos

Hello,

If message body is XML and this needs to be set as header/property in the content modifier,

You could use an XPATH condition in content modifier,

Action	Name	Type	Data Type	Value	Default	
Create	Value1	XPATH	String		substring-before(<xpath to field>, "|")

Regards

Sanjali

anurag_sinha3
Participant
0 Kudos

Hi

i am getting below error :

org.apache.camel.builder.xml.InvalidXPathExpression: Invalid xpath: substring-before{Root/Element/InputParameters "|"}. Reason: javax.xml.xpath.XPathExpressionException: net.sf.saxon.trans.XPathException: Node constructor expressions are allowed only in XQuery, not in XPath, cause: net.sf.saxon.trans.XPathException: Node constructor expressions are allowed only in XQuery, not in XPath