I have an issue in XPath 1.0 where my data is broken up across multiple rows for a single S/N. I need this data pivoted into multiple columns. My sample XML
<?xml version="1.0" encoding="UTF-8"?>
<M3OutDocument>
<DataArea>
<Document>
<Lines>
<Line>
<Materials>
<Material>
<CustomLines>
<Custom>
<MEREMK>111222333</MEREMK>
<PJTX15>VISUAL</PJTX15>
<M8RVAL>Pass1</M8RVAL>
</Custom>
<Custom>
<MEREMK>111222333</MEREMK>
<PJTX15>DIELECTRIC</PJTX15>
<M8RVAL>Fail1</M8RVAL>
</Custom>
<Custom>
<MEREMK>222333444</MEREMK>
<PJTX15>VISUAL</PJTX15>
<M8RVAL>Pass2</M8RVAL>
</Custom>
<Custom>
<MEREMK>222333444</MEREMK>
<PJTX15>DIELECTRIC</PJTX15>
<M8RVAL>Pass3</M8RVAL>
</Custom>
</CustomLines>
</Material>
</Materials>
</Line>
</Lines>
</Document>
</DataArea>
</M3OutDocument>
I need a single row per distinct MEREMK, with one column for each test type (VISUAL, DIELECTRIC, etc.), showing its M8RVAL. I tried using:
/M3OutDocument/DataArea/Document/Subdocument/Lines/Line/Materials/Material/CustomLines/Custom[not(MEREMK = preceding-sibling::Custom/MEREMK)]
And for each Column I have
../Custom[PJTX15='VISUAL']/M8RVAL
etc.
unfortunately this does not work for my data,each test result is returned as the first instance of M8RVAL that matches the PJTX15 condition set.
My expected output would be
MEREMK VISUAL DIELECTRIC
111222333 Pass1 Fail1
222333444 Pass2 Pass3
Please let me know if anything is not clear or if a full XML file is necessary
string([node set])will return the text of the first node.