[xsl] for-each tokenize() and context problem

Subject: [xsl] for-each tokenize() and context problem
From: "Mario Madunic" <Mario_Madunic@xxxxxxxxxxxx>
Date: Thu, 19 Nov 2009 11:27:23 -0600
I have the following variable,

<xsl:variable name="l_GetPartNumber">
  <xsl:for-each select="tokenize(normalize-space($l_Components), ' ')">
    <xsl:variable name="l_Num" select="." />
    <xsl:for-each select="ancestor::*[self::page]/row[entry[1] =
$l_Num]/entry[3]">
      <xsl:value-of select="concat(' ', .)" />
    </xsl:for-each>
  </xsl:for-each>
</xsl:variable>

<xsl:attribute name="partsList" select="normalize-space(concat('- ', $
l_GetPartNumber, ' -'))" />

It is all within a <template match="entry[contains(., ' (Incl. ')]">...</>

$l_Components is a variable that contains a list of numbers stripped from the
last <entry /> and all ranges (7...11) expanded (7 8 9 10 11) and all commas
and ampersands removed. I end up with a tokenized list, such as this "3 5 7 8
9 10 11 13". A sample of the XML is below

<pages>
  <page>
    <row>
      <entry>1</entry><!-- a quirk, can appear multiple times with the same
parent, same value, and have different part numbers (options to the first one
mentioned) -->
      <entry>quantity</entry>
      <entry>part number</entry>
      <entry>part description</entry>
    <row>
    <row>
      <entry>2</entry>
      <entry>quantity</entry>
      <entry>part number</entry>
      <entry>part description, (Incl. 3, 5, 7...11, & 13)</entry>
    <row>
    ...
 </page>
</pages>

The following step is replace the row number with the part number. The XPath
"ancestor::*[self::page]/row[entry[1] = $l_Num]/entry[3]" works outside of the
variable it is in. But once I do the above (var name = l_GetPartNumber), I
receive the following error msg.

Fatal Error! Axis step ancestor::element() cannot be used here: the context
item is an atomic value

Am I going about this the wrong way? Any insight would be appreciated.

Marijan (Mario) Madunic
Publishing Specialist
New Flyer Industries
(204) 934 8815
mario_madunic@xxxxxxxxxxxx


--------------------------------------------------------------------
Please consider the environment before printing this e-mail.

CONFIDENTIALITY STATEMENT: This communication (and  any and all information or
material transmitted with this communication) is confidential, may be
privileged and is intended only for the use of the intended recipient. If you
are not the intended recipient, any review, retransmission, circulation,
distribution, reproduction, conversion to hard copy, copying or other use of
this communication, information or material is strictly prohibited and may be
illegal. If you received this communication in error or if it is forwarded to
you without the express authorization of New Flyer, please notify us
immediately by telephone or by return email and permanently delete the
communication, information and material from any computer, disk drive,
diskette or other storage device or media. Thank you.

Current Thread