Details
-
Bug
-
Status: Resolved
-
Resolution: Fixed
-
2.3
-
None
-
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