Search code examples
xmlxsltxslt-grouping

xsl for-each multiple results filtering


First question on here, so sorry for any formatting errors... I'm having a problem filtering some xml results using xslt 1.0 and have been wracking my brain for a week. I looked around here a bit but couldn't find anything like what I'm trying to do, so I figured I'd ask my own question.

My desired output is a table with rows and columns; can't use actual html here (and i used underscores in place of tabs), so here is a general look:

Process Log for Pressure Tests:

Step 6 - Pressure Test #1 __ Start Time: 09-FEB-2018 14:21:01 __ Duration: 00:45:00
Date Time _____ Pressure (psi) _______ Temperature (°C) _______ Temp 2 (°C) _______ Drain Press (psi) _______
09-FEB-2018 12:21:01 _______ 4.4 _______ 77.8 _______ 80.1 ______ 0.2
09-FEB-2018 12:22:01 _______ 4.3 _______ 77.9 _______ 80.0 ______ 0.2
...
09-FEB-2018 12:55:01 _______ 4.5 _______ 81.7 _______ 88.2 ______ 1.1

Step 8 - Pressure Test #2 __ Start Time: 09-FEB-2018 15:21:01 __ Duration: 00:15:00
Date Time __ Pressure (psi) __ Temperature (°C) __ Temp 2 (°C) __ Drain Press (psi) __
09-FEB-2018 15:21:01 _______ 6.4 _______ 77.8 _______ 80.1 ______ 0.3
09-FEB-2018 15:22:01 _______ 6.3 _______ 77.9 _______ 80.0 ______ 0.1
...
09-FEB-2018 15:35:01 _______ 6.5 _______ 81.7 _______ 88.2 ______ 0.9

The xml source is something like the following:

<folders NODE_NUMBER="87" RUN_START_DATETIME_LOCAL="2018-02-09 15:21:01.000" 
DURATION="15 Mins 00 Secs" START_DATETIME_UTC="2018-02-09 20:21:01.000" 
CONTEXT_SOURCE="1" UTC_EXPLICIT="FALSE" RUN_TYPE="folders" NUMBER="Step 13 - 
Pressure Test #2" START_DATETIME_LOCAL="2018-02-09 15:21:01.000" 
RUN_STOP_DATETIME="09-Feb-2018 15:36:01" IN_PROGRESS="FALSE" 
END_DATETIME_LOCAL="2018-02-09 15:36:01.000" RUN_STOP_DATETIME_LOCAL="2018-02-09 15:36:01.000" RUN_NAME="Step 13 - Pressure Test #2" RUN_START_DATETIME="09-Feb-2018 15:21:01" END_DATETIME="09-Feb-2018 15:36:01" START_SORTTIME="20180209152101" TOTALSECONDS_UTC="900.0" DURATION_UTC="DAY=0000;HR=00;MIN=14;SEC=59;MS=1000;" TOTALSECONDS="900" START_DATETIME="09-Feb-2018 15:21:01" RUN_ID="{301C81C5-5266-4DEA-901D-5D9B2C285CC0}" END_DATETIME_UTC="2018-02-09 20:36:01.000" STOP_SORTTIME="20180209153601" NAME="Step Time Range" VISIBLE="1" REQUIRED="1" OUTPUT_TO_REPORT="1" HIERARCHY_PATH="cycle\folders" START_SOURCE="*" END_SOURCE="*">
<ITEM NODE_NUMBER="88" SORT_ORDER="20" UTC="0" DATASOURCE_ID="10" PSTART="" SOURCE_ID="" TAG="PL" VISIBLE="1" DESCRIPTION="" IDPK="2023" EXEC_CONDITION="" DELIMITER="" PRECISION="1" VERSION="1" OCCURRENCE="" ITEMTYPE="DEFAULT" SOURCE="10-LSV1-XI105/AI1/OUT.CV" OUTPUT_TO_REPORT="1" ID="12062" NAME="Drain Press" DATA_SCOPE="0" PLENGTH="" REQUIRED="1" UOM="psig">
<RESULT NODE_NUMBER="89" TYPE="TABLE" NAME="TABLE" AGGREGATE="INTERPOLATIVE" VISIBLE="1" OUTPUT_TO_REPORT="1">
<RESULT_RECORD DATA="28.8" TIME="09-Feb-2018 15:21:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI105/AI1/OUT.CV"/>
<RESULT_RECORD DATA="46.2" TIME="09-Feb-2018 15:22:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI105/AI1/OUT.CV"/>
<RESULT_RECORD DATA="46.2" TIME="09-Feb-2018 15:23:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI105/AI1/OUT.CV"/>
<RESULT_RECORD DATA="46.2" TIME="09-Feb-2018 15:24:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI105/AI1/OUT.CV"/>
<RESULT_RECORD DATA="46.2" TIME="09-Feb-2018 15:25:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI105/AI1/OUT.CV"/>
<RESULT_RECORD DATA="46.2" TIME="09-Feb-2018 15:26:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI105/AI1/OUT.CV"/>
<RESULT_RECORD DATA="46.2" TIME="09-Feb-2018 15:27:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI105/AI1/OUT.CV"/>
<RESULT_RECORD DATA="21.7" TIME="09-Feb-2018 15:28:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI105/AI1/OUT.CV"/>
<RESULT_RECORD DATA="0.2" TIME="09-Feb-2018 15:29:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI105/AI1/OUT.CV"/>
<RESULT_RECORD DATA="0.2" TIME="09-Feb-2018 15:30:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI105/AI1/OUT.CV"/>
<RESULT_RECORD DATA="0.2" TIME="09-Feb-2018 15:31:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI105/AI1/OUT.CV"/>
<RESULT_RECORD DATA="0.2" TIME="09-Feb-2018 15:32:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI105/AI1/OUT.CV"/>
<RESULT_RECORD DATA="0.2" TIME="09-Feb-2018 15:33:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI105/AI1/OUT.CV"/>
<RESULT_RECORD DATA="0.2" TIME="09-Feb-2018 15:34:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI105/AI1/OUT.CV"/>
<RESULT_RECORD DATA="0.2" TIME="09-Feb-2018 15:35:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI105/AI1/OUT.CV"/>
</RESULT>
<RESULT NODE_NUMBER="90" TYPE="CALC" EVENTVALUE="MINIMUM" VISIBLE="1" OUTPUT_TO_REPORT="1">
<RESULT_RECORD DATA="0.2" RAW_DATA="0.200000" TIME="09-Feb-2018 15:21:01" TAG="10-LSV1-XI105/AI1/OUT.CV"/>
</RESULT>
<RESULT NODE_NUMBER="91" TYPE="CALC" EVENTVALUE="MAXIMUM" VISIBLE="1" OUTPUT_TO_REPORT="1">
<RESULT_RECORD DATA="46.2" RAW_DATA="46.200001" TIME="09-Feb-2018 15:21:01" TAG="10-LSV1-XI105/AI1/OUT.CV"/>
</RESULT>
</ITEM>
<ITEM NODE_NUMBER="92" SORT_ORDER="30" UTC="1" DATASOURCE_ID="10" PSTART="" SOURCE_ID="" TAG="PL" VISIBLE="1" DESCRIPTION="" IDPK="2024" EXEC_CONDITION="" DELIMITER="" PRECISION="1" VERSION="1" OCCURRENCE="" ITEMTYPE="DEFAULT" SOURCE="10-LSV1-XI106/AI1/OUT.CV" OUTPUT_TO_REPORT="1" ID="12065" NAME="Bypass Drain Temp" DATA_SCOPE="0" PLENGTH="" REQUIRED="1" UOM="Deg C">
<RESULT NODE_NUMBER="93" TYPE="TABLE" NAME="TABLE" AGGREGATE="INTERPOLATIVE" VISIBLE="1" OUTPUT_TO_REPORT="1">
<RESULT_RECORD DATA="23.9" TIME="09-Feb-2018 15:21:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI106/AI1/OUT.CV"/>
<RESULT_RECORD DATA="24.1" TIME="09-Feb-2018 15:22:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI106/AI1/OUT.CV"/>
<RESULT_RECORD DATA="24.1" TIME="09-Feb-2018 15:23:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI106/AI1/OUT.CV"/>
<RESULT_RECORD DATA="24.1" TIME="09-Feb-2018 15:24:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI106/AI1/OUT.CV"/>
<RESULT_RECORD DATA="24.1" TIME="09-Feb-2018 15:25:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI106/AI1/OUT.CV"/>
<RESULT_RECORD DATA="24.1" TIME="09-Feb-2018 15:26:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI106/AI1/OUT.CV"/>
<RESULT_RECORD DATA="24.1" TIME="09-Feb-2018 15:27:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI106/AI1/OUT.CV"/>
<RESULT_RECORD DATA="24.1" TIME="09-Feb-2018 15:28:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI106/AI1/OUT.CV"/>
<RESULT_RECORD DATA="24.1" TIME="09-Feb-2018 15:29:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI106/AI1/OUT.CV"/>
<RESULT_RECORD DATA="24.1" TIME="09-Feb-2018 15:30:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI106/AI1/OUT.CV"/>
<RESULT_RECORD DATA="24.1" TIME="09-Feb-2018 15:31:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI106/AI1/OUT.CV"/>
<RESULT_RECORD DATA="24.1" TIME="09-Feb-2018 15:32:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI106/AI1/OUT.CV"/>
<RESULT_RECORD DATA="24.1" TIME="09-Feb-2018 15:33:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI106/AI1/OUT.CV"/>
<RESULT_RECORD DATA="24.1" TIME="09-Feb-2018 15:34:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI106/AI1/OUT.CV"/>
<RESULT_RECORD DATA="24.1" TIME="09-Feb-2018 15:35:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI106/AI1/OUT.CV"/>
</RESULT>
<RESULT NODE_NUMBER="94" TYPE="CALC" EVENTVALUE="MINIMUM" VISIBLE="1" OUTPUT_TO_REPORT="1">
<RESULT_RECORD DATA="23.9" RAW_DATA="23.900000" TIME="09-Feb-2018 15:21:01" TAG="10-LSV1-XI106/AI1/OUT.CV"/>
</RESULT>
<RESULT NODE_NUMBER="95" TYPE="CALC" EVENTVALUE="MAXIMUM" VISIBLE="1" OUTPUT_TO_REPORT="1">
<RESULT_RECORD DATA="24.1" RAW_DATA="24.100000" TIME="09-Feb-2018 15:21:01" TAG="10-LSV1-XI106/AI1/OUT.CV"/>
</RESULT>
</ITEM>
<ITEM NODE_NUMBER="96" SORT_ORDER="40" UTC="1" DATASOURCE_ID="10" PSTART="" SOURCE_ID="" TAG="PL" VISIBLE="1" DESCRIPTION="" IDPK="2025" EXEC_CONDITION="" DELIMITER="" PRECISION="1" VERSION="1" OCCURRENCE="" ITEMTYPE="DEFAULT" SOURCE="10-LSV1-XI107/AI1/OUT.CV" OUTPUT_TO_REPORT="1" ID="12070" NAME="Drain Temp" DATA_SCOPE="0" PLENGTH="" REQUIRED="1" UOM="Deg C">
<RESULT NODE_NUMBER="97" TYPE="TABLE" NAME="TABLE" AGGREGATE="INTERPOLATIVE" VISIBLE="1" OUTPUT_TO_REPORT="1">
<RESULT_RECORD DATA="25.9" TIME="09-Feb-2018 15:21:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI107/AI1/OUT.CV"/>
<RESULT_RECORD DATA="25.5" TIME="09-Feb-2018 15:22:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI107/AI1/OUT.CV"/>
<RESULT_RECORD DATA="25.5" TIME="09-Feb-2018 15:23:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI107/AI1/OUT.CV"/>
<RESULT_RECORD DATA="25.5" TIME="09-Feb-2018 15:24:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI107/AI1/OUT.CV"/>
<RESULT_RECORD DATA="25.5" TIME="09-Feb-2018 15:25:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI107/AI1/OUT.CV"/>
<RESULT_RECORD DATA="25.5" TIME="09-Feb-2018 15:26:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI107/AI1/OUT.CV"/>
<RESULT_RECORD DATA="25.5" TIME="09-Feb-2018 15:27:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI107/AI1/OUT.CV"/>
<RESULT_RECORD DATA="25.5" TIME="09-Feb-2018 15:28:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI107/AI1/OUT.CV"/>
<RESULT_RECORD DATA="25.5" TIME="09-Feb-2018 15:29:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI107/AI1/OUT.CV"/>
<RESULT_RECORD DATA="25.5" TIME="09-Feb-2018 15:30:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI107/AI1/OUT.CV"/>
<RESULT_RECORD DATA="25.5" TIME="09-Feb-2018 15:31:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI107/AI1/OUT.CV"/>
<RESULT_RECORD DATA="25.5" TIME="09-Feb-2018 15:32:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI107/AI1/OUT.CV"/>
<RESULT_RECORD DATA="25.5" TIME="09-Feb-2018 15:33:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI107/AI1/OUT.CV"/>
<RESULT_RECORD DATA="25.5" TIME="09-Feb-2018 15:34:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI107/AI1/OUT.CV"/>
<RESULT_RECORD DATA="25.5" TIME="09-Feb-2018 15:35:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI107/AI1/OUT.CV"/>
</RESULT>
<RESULT NODE_NUMBER="98" TYPE="CALC" EVENTVALUE="MINIMUM" VISIBLE="1" OUTPUT_TO_REPORT="1">
<RESULT_RECORD DATA="25.5" RAW_DATA="25.500000" TIME="09-Feb-2018 15:21:01" TAG="10-LSV1-XI107/AI1/OUT.CV"/>
</RESULT>
<RESULT NODE_NUMBER="99" TYPE="CALC" EVENTVALUE="MAXIMUM" VISIBLE="1" OUTPUT_TO_REPORT="1">
<RESULT_RECORD DATA="25.9" RAW_DATA="25.900000" TIME="09-Feb-2018 15:21:01" TAG="10-LSV1-XI107/AI1/OUT.CV"/>
</RESULT>
</ITEM>
<ITEM NODE_NUMBER="100" SORT_ORDER="50" UTC="1" DATASOURCE_ID="10" PSTART="" SOURCE_ID="" TAG="PL" VISIBLE="1" DESCRIPTION="" IDPK="2026" EXEC_CONDITION="" DELIMITER="" PRECISION="1" VERSION="1" OCCURRENCE="" ITEMTYPE="DEFAULT" SOURCE="10-LSV1-XI104/AI1/OUT.CV" OUTPUT_TO_REPORT="1" ID="12075" NAME="Filter Drain Temp" DATA_SCOPE="0" PLENGTH="" REQUIRED="1" UOM="Deg C">
<RESULT NODE_NUMBER="101" TYPE="TABLE" NAME="TABLE" AGGREGATE="INTERPOLATIVE" VISIBLE="1" OUTPUT_TO_REPORT="1">
<RESULT_RECORD DATA="21.0" TIME="09-Feb-2018 15:21:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI104/AI1/OUT.CV"/>
<RESULT_RECORD DATA="22.3" TIME="09-Feb-2018 15:22:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI104/AI1/OUT.CV"/>
<RESULT_RECORD DATA="22.3" TIME="09-Feb-2018 15:23:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI104/AI1/OUT.CV"/>
<RESULT_RECORD DATA="22.3" TIME="09-Feb-2018 15:24:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI104/AI1/OUT.CV"/>
<RESULT_RECORD DATA="22.3" TIME="09-Feb-2018 15:25:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI104/AI1/OUT.CV"/>
<RESULT_RECORD DATA="22.3" TIME="09-Feb-2018 15:26:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI104/AI1/OUT.CV"/>
<RESULT_RECORD DATA="22.3" TIME="09-Feb-2018 15:27:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI104/AI1/OUT.CV"/>
<RESULT_RECORD DATA="22.3" TIME="09-Feb-2018 15:28:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI104/AI1/OUT.CV"/>
<RESULT_RECORD DATA="22.3" TIME="09-Feb-2018 15:29:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI104/AI1/OUT.CV"/>
<RESULT_RECORD DATA="22.3" TIME="09-Feb-2018 15:30:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI104/AI1/OUT.CV"/>
<RESULT_RECORD DATA="22.3" TIME="09-Feb-2018 15:31:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI104/AI1/OUT.CV"/>
<RESULT_RECORD DATA="22.3" TIME="09-Feb-2018 15:32:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI104/AI1/OUT.CV"/>
<RESULT_RECORD DATA="22.3" TIME="09-Feb-2018 15:33:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI104/AI1/OUT.CV"/>
<RESULT_RECORD DATA="22.3" TIME="09-Feb-2018 15:34:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI104/AI1/OUT.CV"/>
<RESULT_RECORD DATA="22.3" TIME="09-Feb-2018 15:35:01" QUALITY="200C0 (OPCHDA_INTERPOLATED | OPC_QUALITY_GOOD)" TAG="10-LSV1-XI104/AI1/OUT.CV"/>
</RESULT>
<RESULT NODE_NUMBER="102" TYPE="CALC" EVENTVALUE="MINIMUM" VISIBLE="1" OUTPUT_TO_REPORT="1">
<RESULT_RECORD DATA="21.0" RAW_DATA="21.000000" TIME="09-Feb-2018 15:21:01" TAG="10-LSV1-XI104/AI1/OUT.CV"/>
</RESULT>
<RESULT NODE_NUMBER="103" TYPE="CALC" EVENTVALUE="MAXIMUM" VISIBLE="1" OUTPUT_TO_REPORT="1">
<RESULT_RECORD DATA="22.3" RAW_DATA="22.299999" TIME="09-Feb-2018 15:21:01" TAG="10-LSV1-XI104/AI1/OUT.CV"/>
</RESULT>
</ITEM>
</folders>

and my XSL is the following:

  <div>
    <!--ProcessLog-->
    <table class="Item" id="Item_ProcessLog">
      <tr>
        <td COLSPAN="6">
          <h2>Process Log for Pressure Tests:</h2>
        </td>
      </tr>
    </table>
    <table class="Item" width="100%">
      <xsl:for-each select="//folders[@NAME='Step Time Range'][contains(@RUN_NAME,'Pressure Test')]" >
        <tr>
          <td style="text-align:right" colspan="2">
            <b>
              <xsl:value-of select="./@RUN_NAME" />
            </b>
          </td>
          <td style="text-align:center" colspan="2">
                        Start Time: <xsl:value-of select="./@RUN_START_DATETIME" /></td>
          <td style="text-align:left" colspan="2">
                        Duration: 
                        <xsl:variable name="seconds" select="./@TOTALSECONDS_UTC" /><xsl:value-of select="format-number(floor($seconds div 3600), '00')" /><xsl:value-of select="format-number(floor($seconds div 60 mod 60), ':00')" /><xsl:value-of select="format-number($seconds mod 60, ':00')" /></td>
        </tr>
        <tr>
          <th style="text-align:center;">Date Time
                    </th>
          <xsl:for-each select=".//ITEM[@TAG='PL']">
            <th style="text-align:center;">
              <xsl:value-of select="@NAME" />
              <br>
                <xsl:value-of select="@UOM" />
              </br>
            </th>
          </xsl:for-each>
        </tr>
        <xsl:for-each select="(.//ITEM[@TAG='PL'])/RESULT[@TYPE='TABLE']/RESULT_RECORD">
          <xsl:variable name="num" select="position()" />
          <tr>
            <td>
              <xsl:value-of select="@TIME" />
            </td>
            <td>
              <xsl:value-of select="@DATA" />
            </td>
          </tr>
        </xsl:for-each>
      </xsl:for-each>
    </table>
  </div>

Its "working" so far as to display the date/time for each result and only the first column of data. I cannot for the life of me get the output of all four columns of data. I have a different stylesheet that works with the same xsl that displays all data, not just these multiple subsets of data.

Anyone have any thoughts or tips would be greatly appreciated! Thanks for taking the time to look at my question :)


Solution

  • The data to be displayed column-wise is fetched from different index of <ITEM> element viz. Drain Press is fetched from <RESULT_RECORD> elements present under ITEM[1], Bypass Drain Temp is fetched from <RESULT_RECORD> elements present under ITEM[2] and so on.

    The combination of muenchian grouping and normal <xsl:for-each> can be used to get the desired output. An outer loop on the <folders> element is started which is same as the shared XSL.

    <xsl:for-each select="//folders[@NAME='Step Time Range'][contains(@RUN_NAME,'Pressure Test')]">
    

    Within this loop, the header row and column headers can be built. I have modified the shared code snippet to use the concat() function instead of successive <xsl:value-of>.

    <tr>
        <td style="text-align:right" colspan="2">
            <b>
                <xsl:value-of select="@RUN_NAME" />
            </b>
        </td>
        <td style="text-align:center" colspan="2">
            <xsl:value-of select="concat('Start Time: ', @RUN_START_DATETIME)" />
        </td>
        <td style="text-align:left">
            <xsl:variable name="totalSeconds" select="@TOTALSECONDS_UTC" />
            <xsl:variable name="hours" select="format-number(floor($totalSeconds div 3600), '00')" />
            <xsl:variable name="minutes" select="format-number(floor($totalSeconds div 60 mod 60), ':00')" />
            <xsl:variable name="seconds" select="format-number($totalSeconds mod 60, ':00')" />
            <xsl:value-of select="concat('Duration: ', $hours, $minutes, $seconds)" />
        </td>
    </tr>
    <tr>
        <th style="text-align:center;">Date Time</th>
        <xsl:for-each select="ITEM[@TAG='PL']">
            <th style="text-align:center;">
                <xsl:value-of select="@NAME" />
                <br>
                    <xsl:value-of select="@UOM" />
                </br>
            </th>
        </xsl:for-each>
    </tr>
    

    For fetching and displaying the individual column-wise data, muenchian grouping is used. A key is defined to group together the <RESULT_RECORD> having @QUALITY attribute based on the value of @TIME attribute. @QUALITY attribute filter is used to exclude other <RESULT_RECORD> elements not required for extracting data.

    <xsl:key name="groupKey" match="RESULT_RECORD[@QUALITY]" use="@TIME" />
    

    A nested loop is run on the grouped elements and is used to fetch the @TIME and @DATA

    <xsl:for-each select="//RESULT_RECORD[@QUALITY][generate-id() = generate-id(key('groupKey', @TIME)[1])]">
        <tr>
            <td style="text-align:center;">
                <xsl:value-of select="@TIME" />
            </td>
            <xsl:for-each select="key('groupKey', @TIME)">
                <td style="text-align:center;">
                    <xsl:value-of select="@DATA" />
                </td>
            </xsl:for-each>
        </tr>
    </xsl:for-each>
    

    The entire XSLT is as below

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="html" />
        <xsl:strip-space elements="*" />
    
        <xsl:key name="groupKey" match="RESULT_RECORD[@QUALITY]" use="@TIME" />
    
        <xsl:template match="/">
            <div>
                <!--ProcessLog -->
                <table class="Item" id="Item_ProcessLog" border="1">
                    <tr>
                        <td COLSPAN="5">
                            <h2>Process Log for Pressure Tests:</h2>
                        </td>
                    </tr>
                </table>
                <table class="Item" width="100%" border="1">
                    <xsl:for-each select="//folders[@NAME='Step Time Range'][contains(@RUN_NAME,'Pressure Test')]">
                        <tr>
                            <td style="text-align:right" colspan="2">
                                <b>
                                    <xsl:value-of select="@RUN_NAME" />
                                </b>
                            </td>
                            <td style="text-align:center" colspan="2">
                                <xsl:value-of select="concat('Start Time: ', @RUN_START_DATETIME)" />
                            </td>
                            <td style="text-align:left">
                                <xsl:variable name="totalSeconds" select="@TOTALSECONDS_UTC" />
                                <xsl:variable name="hours" select="format-number(floor($totalSeconds div 3600), '00')" />
                                <xsl:variable name="minutes" select="format-number(floor($totalSeconds div 60 mod 60), ':00')" />
                                <xsl:variable name="seconds" select="format-number($totalSeconds mod 60, ':00')" />
                                <xsl:value-of select="concat('Duration: ', $hours, $minutes, $seconds)" />
                            </td>
                        </tr>
                        <tr>
                            <th style="text-align:center;">Date Time</th>
                            <xsl:for-each select="ITEM[@TAG='PL']">
                                <th style="text-align:center;">
                                    <xsl:value-of select="@NAME" />
                                    <br>
                                        <xsl:value-of select="@UOM" />
                                    </br>
                                </th>
                            </xsl:for-each>
                        </tr>
                        <xsl:for-each select="//RESULT_RECORD[@QUALITY][generate-id() = generate-id(key('groupKey', @TIME)[1])]">
                            <tr>
                                <td style="text-align:center;">
                                    <xsl:value-of select="@TIME" />
                                </td>
                                <xsl:for-each select="key('groupKey', @TIME)">
                                    <td style="text-align:center;">
                                        <xsl:value-of select="@DATA" />
                                    </td>
                                </xsl:for-each>
                            </tr>
                        </xsl:for-each>
                    </xsl:for-each>
                </table>
            </div>
        </xsl:template>
    </xsl:stylesheet>
    

    The image of the output can be found in the attachment. I have added a border to the table for ease of understanding. Feel free to remove it.

    Output Data Table