Uploaded image for project: 'XalanJ2'
  1. XalanJ2
  2. XALANJ-1096

current() throws NullPointerException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Resolution: Fixed
    • 2.3
    • None
    • XPath
    • None
    • Operating System: Windows NT/2K
      Platform: PC
    • 10900

    Description

      I get a NullPointerException which seems to happen when the current() function
      is called in the stylesheet below, when called with the supplied XML document.

      Stylesheet
      ==========
      <?xml version="1.0" encoding="UTF-8"?>
      <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="xml" version="1.0" encoding="UTF-8"/>

      <!-- Batch template -->
      <xsl:template match="/ECHBATCH">
      <SWBATCH>
      <xsl:apply-templates/>
      </SWBATCH>
      </xsl:template>

      <!-- Prevent copying the content of elements that are not recognised directly –
      >
      <xsl:template match="/ECHBATCH/MESSAGE/*"/>

      <xsl:template match="/ECHBATCH/MESSAGE/MEDTD1">
      <BSTSUPD>
      <xsl:for-each select="../MEDTD2">
      <METERED_USAGE>
      <!-- Previous meter reading -->
      <xsl:if test="following-sibling::MEDTD3[count(preceding-
      sibling::MEDTD2[1]|current())=1 and QUANTITY_TYPE_ID='220' and
      QUANTITY_DATE_TYPE='367']">
      <METER_PREV>
      <METER_READING_1><xsl:value-of select="(following-
      sibling::MEDTD3[count(preceding-sibling::MEDTD2[1]|current())=1 and
      QUANTITY_TYPE_ID='220' and QUANTITY_DATE_TYPE='367'])
      [1]/QUANTITY"/></METER_READING_1>
      <METER_READING_2><xsl:value-of select="(following-
      sibling::MEDTD3[count(preceding-sibling::MEDTD2[1]|current())=1 and
      QUANTITY_TYPE_ID='220' and QUANTITY_DATE_TYPE='367'])
      [2]/QUANTITY"/></METER_READING_2>
      <TIMEFRAME_ID_1><xsl:value-of select="(following-sibling::MEDTD3
      [count(preceding-sibling::MEDTD2[1]|current())=1 and QUANTITY_TYPE_ID='220' and
      QUANTITY_DATE_TYPE='367'])[1]/TIMEFRAME_ID"/></TIMEFRAME_ID_1>
      <TIMEFRAME_ID_2><xsl:value-of select="(following-sibling::MEDTD3
      [count(preceding-sibling::MEDTD2[1]|current())=1 and QUANTITY_TYPE_ID='220' and
      QUANTITY_DATE_TYPE='367'])[2]/TIMEFRAME_ID"/></TIMEFRAME_ID_2>
      <METER_READING_TYPE><xsl:value-of select="(following-
      sibling::MEDTD3[count(preceding-sibling::MEDTD2[1]|current())=1 and
      QUANTITY_TYPE_ID='220' and
      QUANTITY_DATE_TYPE='367'])/QUALIFICATION"/></METER_READING_TYPE>
      <METER_READING_DATE_TYPE>367</METER_READING_DATE_TYPE>
      <METER_READING_DATE><xsl:value-of select="(following-
      sibling::MEDTD3[count(preceding-sibling::MEDTD2[1]|current())=1 and
      QUANTITY_TYPE_ID='220' and
      QUANTITY_DATE_TYPE='367'])/QUANTITY_DATE"/></METER_READING_DATE>
      <UNIT_OF_MEASURE_ID><xsl:value-of select="(following-
      sibling::MEDTD3[count(preceding-sibling::MEDTD2[1]|current())=1 and
      QUANTITY_TYPE_ID='220' and
      QUANTITY_DATE_TYPE='367'])/MEASURE_UNIT_ID"/></UNIT_OF_MEASURE_ID>
      </METER_PREV>
      </xsl:if>
      </METERED_USAGE>
      </xsl:for-each>
      </BSTSUPD>
      </xsl:template>

      </xsl:stylesheet>

      Example XML file
      ================
      <?xml version="1.0" encoding="UTF-8"?>
      <ECHBATCH>
      <HEADER>
      <MESSAGE_ID>210</MESSAGE_ID>
      <FILENAME>ECH210_20020601_0000.dat</FILENAME>
      <TIMESTAMP>20020601_0000</TIMESTAMP>
      <VERSION>2.0</VERSION>
      <SENDER_EAN>8712423010208</SENDER_EAN>
      <RECEIVER_EAN>8712423009714</RECEIVER_EAN>
      </HEADER>
      <MESSAGE>
      <MEDTD1>
      <RECORD_ID>MEDTD1</RECORD_ID>
      <SWITCH_ID>12345</SWITCH_ID>
      <CONNECT_EAN>887766554401480009</CONNECT_EAN>
      <REASON_ID>E03</REASON_ID>
      <PERIOD_START_DATE>20020101</PERIOD_START_DATE>
      <PERIOD_END_DATE>20020401</PERIOD_END_DATE>
      <SUBMITTED_DATE>20020501</SUBMITTED_DATE>
      <SUBMITTED_TIME>1200</SUBMITTED_TIME>
      <MARKET_SEGMENT>23</MARKET_SEGMENT>
      <NET_OP_EAN>8700000000003</NET_OP_EAN>
      </MEDTD1>
      <MEDTD2>
      <RECORD_ID>MEDTD2</RECORD_ID>
      <METERNO>123456789012345678</METERNO>
      <NO_DIALS>19</NO_DIALS>
      </MEDTD2>
      <MEDTD3>
      <RECORD_ID>MEDTD3</RECORD_ID>
      <QUANTITY>1234657890.0</QUANTITY>
      <QUANTITY_TYPE_ID>220</QUANTITY_TYPE_ID>
      <QUANTITY_DATE>20020501</QUANTITY_DATE>
      <QUANTITY_DATE_TYPE>367</QUANTITY_DATE_TYPE>
      <MEASURE_UNIT_ID>KWH</MEASURE_UNIT_ID>
      <TIMEFRAME_ID>E10</TIMEFRAME_ID>
      <QUALIFICATION>81</QUALIFICATION>
      <NO_DIGITS>10</NO_DIGITS>
      </MEDTD3>
      <MEDTD3>
      <RECORD_ID>MEDTD3</RECORD_ID>
      <QUANTITY>1234657890.0</QUANTITY>
      <QUANTITY_TYPE_ID>220</QUANTITY_TYPE_ID>
      <QUANTITY_DATE>20020501</QUANTITY_DATE>
      <QUANTITY_DATE_TYPE>367</QUANTITY_DATE_TYPE>
      <MEASURE_UNIT_ID>KWH</MEASURE_UNIT_ID>
      <TIMEFRAME_ID>E11</TIMEFRAME_ID>
      <QUALIFICATION>81</QUALIFICATION>
      <NO_DIGITS>10</NO_DIGITS>
      </MEDTD3>
      </MESSAGE>
      <MESSAGE>
      <MEDTD1>
      <RECORD_ID>MEDTD1</RECORD_ID>
      <REQUEST_ID>12345</REQUEST_ID>
      <CONNECT_EAN>887766554401490008</CONNECT_EAN>
      <REASON_ID>001</REASON_ID>
      <PERIOD_START_DATE>20020101</PERIOD_START_DATE>
      <PERIOD_END_DATE>20020401</PERIOD_END_DATE>
      <SUBMITTED_DATE>20020501</SUBMITTED_DATE>
      <SUBMITTED_TIME>1200</SUBMITTED_TIME>
      <MARKET_SEGMENT>23</MARKET_SEGMENT>
      <NET_OP_EAN>8700000000003</NET_OP_EAN>
      </MEDTD1>
      <MEDTD2>
      <RECORD_ID>MEDTD2</RECORD_ID>
      <METERNO>123456789012345678</METERNO>
      <NO_DIALS>19</NO_DIALS>
      </MEDTD2>
      <MEDTD3>
      <RECORD_ID>MEDTD3</RECORD_ID>
      <QUANTITY>1234657890.0</QUANTITY>
      <QUANTITY_TYPE_ID>220</QUANTITY_TYPE_ID>
      <QUANTITY_DATE>20020501</QUANTITY_DATE>
      <QUANTITY_DATE_TYPE>367</QUANTITY_DATE_TYPE>
      <MEASURE_UNIT_ID>KWH</MEASURE_UNIT_ID>
      <TIMEFRAME_ID>E10</TIMEFRAME_ID>
      <QUALIFICATION>86</QUALIFICATION>
      <NO_DIGITS>10</NO_DIGITS>
      </MEDTD3>
      <MEDTD3>
      <RECORD_ID>MEDTD3</RECORD_ID>
      <QUANTITY>1234657890.0</QUANTITY>
      <QUANTITY_TYPE_ID>220</QUANTITY_TYPE_ID>
      <QUANTITY_DATE>20020501</QUANTITY_DATE>
      <QUANTITY_DATE_TYPE>367</QUANTITY_DATE_TYPE>
      <MEASURE_UNIT_ID>KWH</MEASURE_UNIT_ID>
      <TIMEFRAME_ID>E11</TIMEFRAME_ID>
      <QUALIFICATION>86</QUALIFICATION>
      <NO_DIGITS>10</NO_DIGITS>
      </MEDTD3>
      </MESSAGE>
      <MESSAGE>
      <MEDTD1>
      <RECORD_ID>MEDTD1</RECORD_ID>
      <REQUEST_ID>12345</REQUEST_ID>
      <CONNECT_EAN>887766554401500004</CONNECT_EAN>
      <REASON_ID>E24</REASON_ID>
      <PERIOD_START_DATE>20020101</PERIOD_START_DATE>
      <PERIOD_END_DATE>20020401</PERIOD_END_DATE>
      <SUBMITTED_DATE>20020501</SUBMITTED_DATE>
      <SUBMITTED_TIME>1200</SUBMITTED_TIME>
      <MARKET_SEGMENT>23</MARKET_SEGMENT>
      <NET_OP_EAN>8700000000003</NET_OP_EAN>
      </MEDTD1>
      <MEDTD2>
      <RECORD_ID>MEDTD2</RECORD_ID>
      <METERNO>123456789012345678</METERNO>
      <NO_DIALS>19</NO_DIALS>
      </MEDTD2>
      <MEDTD3>
      <RECORD_ID>MEDTD3</RECORD_ID>
      <QUANTITY>1234657890.0</QUANTITY>
      <QUANTITY_TYPE_ID>220</QUANTITY_TYPE_ID>
      <QUANTITY_DATE>20020501</QUANTITY_DATE>
      <QUANTITY_DATE_TYPE>367</QUANTITY_DATE_TYPE>
      <MEASURE_UNIT_ID>KWH</MEASURE_UNIT_ID>
      <TIMEFRAME_ID>E10</TIMEFRAME_ID>
      <QUALIFICATION>86</QUALIFICATION>
      <NO_DIGITS>10</NO_DIGITS>
      </MEDTD3>
      <MEDTD3>
      <RECORD_ID>MEDTD3</RECORD_ID>
      <QUANTITY>1234657890.0</QUANTITY>
      <QUANTITY_TYPE_ID>220</QUANTITY_TYPE_ID>
      <QUANTITY_DATE>20020501</QUANTITY_DATE>
      <QUANTITY_DATE_TYPE>367</QUANTITY_DATE_TYPE>
      <MEASURE_UNIT_ID>KWH</MEASURE_UNIT_ID>
      <TIMEFRAME_ID>E10</TIMEFRAME_ID>
      <QUALIFICATION>86</QUALIFICATION>
      <NO_DIGITS>10</NO_DIGITS>
      </MEDTD3>
      </MESSAGE>
      </ECHBATCH>

      Jesper de Jong

      Attachments

        1. ASF.LICENSE.NOT.GRANTED--bug.xml
          5 kB
          Jesper de Jong
        2. ASF.LICENSE.NOT.GRANTED--bug.xsl
          3 kB
          Jesper de Jong
        3. ASF.LICENSE.NOT.GRANTED--bug10900.patch
          0.8 kB
          Morris Kwan
        4. ASF.LICENSE.NOT.GRANTED--patch_10900.txt
          4 kB
          Igor Hersht
        5. ASF.LICENSE.NOT.GRANTED--patch_10900.txt
          1 kB
          Igor Hersht
        6. ASF.LICENSE.NOT.GRANTED--patch10900.txt
          4 kB
          Igor Hersht
        7. ASF.LICENSE.NOT.GRANTED--skinny.xml
          0.1 kB
          Morris Kwan
        8. ASF.LICENSE.NOT.GRANTED--skinny.xsl
          1.0 kB
          Morris Kwan

        Activity

          People

            igorh@ca.ibm.com Igor Hersht
            jespdj@hotmail.com Jesper de Jong
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: