Using a tree read with document() as a hash-table

Subject: Using a tree read with document() as a hash-table
From: Thorbjørn Ravn Andersen <TRA@xxxxxxxx>
Date: Wed, 14 Jun 2000 11:16:03 +0200
My problem is that I need to look up a value in another external XML file during XSLT processing, to include in the generated output.

I can read in the external file with the following lines

<xsl:param name="packtypefile" select="packtype.xml" />
<!-- Load the packtypes from the external file -->
<xsl:variable name="packtypetree" select="document(packtypefile)" saxon:trace="yes"/>

which is rather small and looks like

<ROWSET><!-- Warning:  This is not using approved tag names!  Beware-->
<ROW><id>0</id><packcode></packcode><ordertxt>%d</ordertxt><ssmtxt>%d</ssmtxt><modultxt>price each</modultxt></ROW>
<ROW><id>1</id><packcode>KT</packcode><ordertxt>1 Kit of %d</ordertxt><ssmtxt>1 kit</ssmtxt><modultxt>price per kit</modultxt></ROW>
<ROW><id>2</id><packcode>BAG</packcode><ordertxt>1 Bag of %d</ordertxt><ssmtxt>1 bag</ssmtxt><modultxt>price per bag</modultxt></ROW>
...


During the XSLT processing, I have the packcode as a subnode of the current node, and I need the corresponding value of the <modultxt> tag for output.

I have done a lot of trial-and-error, and have given up on the following


  <!-- First look up the packtype -->
  <xsl:apply-templates select="$packtypetree//ROW[packcode='GREEL']" mode="preview"/>

to get "into" the node-set of $packtypetree, but without visible results. 

I would appreciate a nudge in the right direction.  Am I on the right track?

Thanks in advance.
-- 
  Thorbjørn Ravn Andersen      "... plus ... Tubular Bells!"


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread