XPATH is giving result in comma separated values
rkhapre opened this issue · 1 comments
rkhapre commented
Hi
I have a XML in this format, which has around 2K records of
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns0:advancedSearchResponse xmlns:ns0="http://xmlns.xyz.com/Objects/V1">
<response>
<messageId xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<messageName xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<statusCode>SUCCESS</statusCode>
<table>
<tableIdentifier>
<classId xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<className xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<objectId>6151127</objectId>
<objectName xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<tableId>-102</tableId>
<tableName xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<tableDisplayName xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
</tableIdentifier>
<row rowId="1">
<objectReferentId>
<classId>2468022</classId>
<className>BondWire</className>
<classDisplayName xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<objectId>6118882</objectId>
<objectName xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<objectVersion xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<version xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
</objectReferentId>
<additionalRowInfo xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<number attributeId="1001" xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">22</number>
<Type attributeId="1081" xsi:type="common:ListEntryType" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:common="http://xmlns.xyz.com/Objects/Core/Common/V1">
<listName xsi:nil="true"/>
<selection>
<id>2468022</id>
<apiName>BondWire</apiName>
<value>Bond Wire</value>
</selection>
</Type>
<description attributeId="1002" xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">Lifecycle Phase Testing Part, Testing Comma, OKay</description>
<phase attributeId="1084" xsi:type="common:ListEntryType" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:common="http://xmlns.xyz.com/Objects/Core/Common/V1">
<listName xsi:nil="true"/>
<selection>
<id>2481963</id>
<apiName>ACTIVE_PHASE</apiName>
<value>Active Phase</value>
</selection>
</phase>
</row>
</table>
</response>
</ns0:advancedSearchResponse>
</S:Body>
</S:Envelope>
My xml filter is like this
xml {
source => "message"
target => "message_parsed"
add_tag => ["xml_parsed"]
remove_namespaces => true
store_xml => true
force_array => true
xpath => [
"/Envelope/Body/advancedSearchResponse/response/table/row/number/text()","number",
"/Envelope/Body/advancedSearchResponse/response/table/row/type/selection/value/text()","type",
"/Envelope/Body/advancedSearchResponse/response/table/row/description/text()","description",
"/Envelope/Body/advancedSearchResponse/response/table/row/phase/selection/value/text()","phase"
]
}
I get the result in comma separated fashion. It should give me in multiple event.
I feel this is a bug in XPATH
number : 22,23,24,25,....
type: Bond Wire,abc, def, ghi....
description: desc1, desc2......
phase: phase1,phase2.... etc.
My expected result is, number should have 4 events. Currently it comes as only 1 event in comma seperated format
number
22
23
24
25
rkhapre commented
This is not a issue now. I did workaround
Transpose the comma separated value and then converted to array with hash (key=>value)
and then used split filter to get result