0

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

5
  • Depends on the test implementation. Keep in mind that several XPath functions apply to the first node of the set, e.g. string([node set]) will return the text of the first node. Commented Jul 8 at 21:22
  • 1
    While asking a question, you need to provide a minimal reproducible example: Please edit your original question and provide the following: (1) Well-formed XML file sample with all relevant namespaces. (2) What you need to do, i.e. logic, and your code attempt trying to implement it. (3) Desired output based on the sample data in #1 above. Commented Jul 8 at 22:25
  • Updated question to better align Commented Jul 9 at 14:06
  • What tool are you using to run your multiple XPath expressions? For whole document transformations consider it's sibling XSLT. Commented Jul 12 at 16:15
  • Infor's IDM Word Plugin, I believe it's fairly niche and does not support anything besides XPath 1.0. And unfortunately the data preprocessing in the M3 ERP is equally limiting Commented Jul 16 at 18:57

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.