[xsl] key usage and evaluate function

Subject: [xsl] key usage and evaluate function
From: DERHILLE Magalie - 8686 <DERHILLE@xxxxxxx>
Date: Tue, 16 Nov 2004 08:18:02 +0100
Hi there,

The purpose of the transformation is to display the data (namespace 'data')
as an HTML table by merging a table layout definition (namespace 'mydata')
and its xml data.

I would like to sort rows by the type of event using a key, to do so I build
a string representation based on the key, the problem occurs when I evaluate
the string with xalan:evaluate from my table builder (the "AddRows" template
from toolbox.xsl), it seems that the result is empty because I get this
error message:
" SystemID: file:/c:/Development/Workstation/resource/toolbox.xsl; Line#:
233; Column#: -1 javax.xml.transform.TransformerException:
java.lang.NullPointerException"

Should it be that evaluating a key doesn't work?

The result should be of the following format:

APPROVAL
15/01/2004  APPROVAL  PENDING  APPROVED  SMITH  Approved without problems
01/01/2004  APPROVAL  PENDING  PENDING  SMITH  Approval did not work due to
errors
TRANSFER
01/01/2004  TRANSFER  NULL  PENDING  MONROE  Transfer OK

So I've been on it for 2 days now, I must do something wrong but I cannot
figure out what.
I would appreciate some help.

Thanks,
Magalie Derhille

The different pieces of code:

Key definition in screen.xsl is:
  <xsl:key name="by-event"
match="/data:SERAPIS/data:SQLDATA/data:DATASET[@key='HISTORY']/data:ROW"
use="data:COL[@key='EVE.ABR_EVENEMENT_ANG']/text() " />

****************************************************************************
************************************************
Data are presented in that form that match with the namespace 'data' in
screen.xsl:

		<DATASET key="HISTORY">
			<ROW>
				<COL
key="AFF.DAT_EVENEMENT">15/01/2004</COL>
				<COL
key="EVE.ABR_EVENEMENT_ANG">APPROVAL</COL>
				<COL key="STA_AVANT.ABR_STATUT_AFFECT
">PENDING</COL>
				<COL key="STA_APRES.ABR_STATUT_AFFECT
">APPROVED</COL>
				<COL key="AFF.OPER_EVENEMENT">SMITH</COL>
				<COL key="AFF.EVENEMENT_COMMENT">Approved
without problems></COL>
			</ROW>
			<ROW>
				<COL
key="AFF.DAT_EVENEMENT">01/01/2004</COL>
				<COL
key="EVE.ABR_EVENEMENT_ANG">TRANSFER</COL>
				<COL key="STA_AVANT.ABR_STATUT_AFFECT
">NULL</COL>
				<COL key="STA_APRES.ABR_STATUT_AFFECT
">PENDING</COL>
				<COL key="AFF.OPER_EVENEMENT">MONROE</COL>
				<COL key="AFF.EVENEMENT_COMMENT">Transfer
OK</COL>
			</ROW>
			<ROW>
				<COL
key="AFF.DAT_EVENEMENT">01/01/2004</COL>
				<COL
key="EVE.ABR_EVENEMENT_ANG">APPROVAL</COL>
				<COL key="STA_AVANT.ABR_STATUT_AFFECT
">PENDING</COL>
				<COL key="STA_APRES.ABR_STATUT_AFFECT
">PENDING</COL>
				<COL key="AFF.OPER_EVENEMENT">SMITH</COL>
				<COL key="AFF.EVENEMENT_COMMENT">Approval
did not work due to errors</COL>
			</ROW>
		</DATASET>
****************************************************************************
************************************************

in screen.xsl there's some xml for table definition ('mydata' namespace) of
that type:

<mydata:Rows name="RowsFiltered">

    	<xsl:for-each
select="/data:SERAPIS/data:SQLDATA/data:DATASET[@key='HISTORY']/data:ROW[cou
nt(. | key('by-event', data:COL[@key='EVE.ABR_EVENEMENT_ANG']/text() )[1]) =
1]">

		<xsl:variable name="currentEventValue"
select="data:COL[@key='EVE.ABR_EVENEMENT_ANG']/text()"/>

		<mydata:Row multirow="key('by-event',
'{$currentEventValue}')" key='yes' ">
			<mydata:Col style="text-align:left">
				<mydata:Label
execute="yes">/data:COL[@key='AFF.DAT_EVENEMENT']</mydata:Label>
			</mydata:Col>
			<mydata:Col style="text-align:left">
				<mydata:Label
execute="yes">/data:COL[@key='EVE.ABR_EVENEMENT_ANG']</mydata:Label>
			</mydata:Col>
			<mydata:Col style="text-align:right">
				<mydata:Label
execute="yes">/data:COL[@key='STA_AVANT.ABR_STATUT_AFFECT ']</mydata:Label>
			</mydata:Col>
			<mydata:Col style="text-align:right">
				<mydata:Label
execute="yes">/data:COL[@key='STA_APRES.ABR_STATUT_AFFECT ']</mydata:Label>
			</mydata:Col>
			<mydata:Col style="text-align:right">
				<mydata:Label
execute="yes">/data:COL[@key='AFF.OPER_EVENEMENT']</mydata:Label>
			</mydata:Col>
			<mydata:Col style="text-align:left">
				<mydata:Label
execute="yes">/data:COL[@key='AFF.EVENEMENT_COMMENT']</mydata:Label>
			</mydata:Col>
		</mydata:Row>

	</xsl:for-each>
</mydata:Rows>

****************************************************************************
************************************************

and finally the building of the HTML table is done that way from sceen.xsl

							<table
class="subSectionDatatable" width="98%">

<xsl:variable name="rowsDef">

<xsl:call-template name="filterTable"/>

</xsl:variable>

<xsl:variable name="rowsDefTemp" select="xalan:nodeset($rowsDef)"/>

<xsl:variable name="rowsNodeSet"
select="$rowsDefTemp/mydata:Rows[@name='RowsFiltered']"/>

<xsl:call-template name="AddHeader">

<xsl:with-param name="HeadDef" select="$HeadDocumentsDef"/>

</xsl:call-template>

<xsl:call-template name="AddRows">

<xsl:with-param name="RowsDef" select="$rowsNodeSet"/>

</xsl:call-template>
							</table>

****************************************************************************
************************************************

the 'AddRows' template is located in toolbox.xsl which is included in the
screen.xsl

  <xsl:template name="AddRows">
		<xsl:param name="RowsDef"/>
		<xsl:variable name="OddRow" select="$RowsDef/@OddRow"/>
		<xsl:variable name="EvenRow" select="$RowsDef/@EvenRow"/>
		<xsl:variable name="here" select="."/>
		<xsl:for-each select="$RowsDef/mydata:Row">
        		<xsl:variable name="RowPos" select="position()"/>
			<xsl:choose>
				<xsl:when test="@key='yes'">
					<xsl:variable name="tempval2eval">
						<xsl:value-of
select="@multirow"/>
					</xsl:variable>
					<xsl:variable name="tempevaluated"
select="xalan:evaluate($tempval2eval)"/>
					<xsl:for-each
select="$tempevaluated">
						<xsl:variable
name="Position" select="position()"/>
						<xsl:call-template
name="AddRowCells">
							<xsl:with-param
name="OddRow" select="$OddRow"/>
							<xsl:with-param
name="EvenRow" select="$EvenRow"/>
							<xsl:with-param
name="Position" select="$Position"/>
							<xsl:with-param
name="Multirow" select="not(false())"/>
						    <xsl:with-param
name="here" select="$here"/>
							<xsl:with-param
name="ColDef" select="xalan:nodeset($RowsDef/mydata:Row[position() =
$RowPos])"/>
						</xsl:call-template>
					</xsl:for-each>
				</xsl:when>
				<xsl:when test="@multirow and @multirow !=
''">
							[...]
				</xsl:when>
			</xsl:choose>
		</xsl:for-each>
	</xsl:template>


--------------------------------------------------------------------

Les informations contenues dans ce message et/ou ses annexes sont
rC)servC)es C  l'attention et C  l'utilisation de leur destinataire et
peuvent C*tre confidentielles. Si vous n'C*tes pas destinataire de ce
message, vous C*tes informC)s que vous l'avez reC'u par erreur et que
toute utilisation en est interdite. Dans ce cas, vous C*tes priC)s de
le dC)truire et d'en informer la Banque europC)enne d'investissement.

The information in this message and/or attachments is intended
solely for the attention and use of the named addressee and may be
confidential. If you are not the intended recipient, you are hereby
notified that you have received this transmittal in error and that
any use of it is prohibited. In such a case please delete this
message and kindly notify the European Investment Bank accordingly.

Current Thread