RE: [xsl] Cannot select a node here: the context item is undefined

Subject: RE: [xsl] Cannot select a node here: the context item is undefined
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 5 Apr 2005 23:24:00 +0100
The key() function has an implicit dependency on the context node - unless
you supply the new third argument, it searches the current document, defined
as the document containing the context node. But inside an xsl:function,
there is no context node unless you create one. Functions have no implicit
parameters.

If the call on key() is always searching the principal source document of
the transformation, you can set up the usual global variable

<xsl:variable name="root" select="/"/>

and use $root as the third argument of key().

If it's searching different documents on different occasions, then you need
to add another parameter to the function.

Michael Kay
http://www.saxonica.com/  

> -----Original Message-----
> From: Jim_Albright@xxxxxxxxxxxx [mailto:Jim_Albright@xxxxxxxxxxxx] 
> Sent: 05 April 2005 22:36
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Cannot select a node here: the context item is 
> undefined
> 
> Again thank you all for your great responses. I just about have this 
> project completed.
> 
> I am using Saxon 8.3
> 
> the piece of the stylesheet giving the error message is >>>marked<<<<<
>         <xsl:key name="word-group-by-word" match="word-group" 
> use="word"/>
>         <xsl:function name="str:find_root_word" as="xs:string">
>                 <xsl:param name="word" as="xs:string"/>
>                 <xsl:variable name="length-of-word" select="
> string-length($word)"  />
>                 <xsl:choose>
>                         <!-- this should remove the 'ed' -->
> >>>>>   <xsl:when test="key('word-group-by-word',substring($word,1, 
> $length-of-word - 2))"> <<<<<<<<<<<<<<<<<<
>                                 <xsl:sequence 
> select="substring($word,1, 
> $length-of-word - 2)"/>
>                         </xsl:when>
> 
> So what is the error? Cannot select a node here: the context item is 
> undefined
>  
> What I am trying to do.
> I have words in word-group that I am trying to analyze. If the 
> master-count is non-zero then I am happy that we have the 
> word found in a 
> Bible and in the master list e.g., falter.
> 
> If the master-count is null then it should be flagged as a 
> possible error. 
> But since  the last three words are only variations of the first word 
> listed below I would like to exclude them as problems. 
>         <word>falter</word>
>         <word>faltered</word>
>         <word>faltering</word>
>         <word>falters</word>
> 
> 
> piece of xml file:
> <word-group>
>         <word>falter</word>
>         <master-count>1</master-count>
>         <master-number>9.4.3.1.5; </master-number>
>         <master-name>Uncertain; </master-name>
>         <niv-count>2</niv-count>
>         <nasb-count>1</nasb-count>
>         <nlt-count>1</nlt-count>
>         <tev-count/>
>         <niv-references>PRO 24:10 ISA 42:4</niv-references>
>         <nasb-references>LEV 25:35</nasb-references>
>         <nlt-references>MAT 21:26</nlt-references>
>         <tev-references/>
> </word-group>
> <word-group>
>         <word>faltered</word>
>         <master-count/>
>         <master-number/>
>         <master-name/>
>         <niv-count>1</niv-count>
>         <nasb-count/>
>         <nlt-count/>
>         <tev-count/>
>         <niv-references>PSA 105:37</niv-references>
>         <nasb-references/>
>         <nlt-references/>
>         <tev-references/>
> </word-group>
> <word-group>
>         <word>faltering</word>
>         <master-count/>
>         <master-number/>
>         <master-name/>
>         <niv-count>3</niv-count>
>         <nasb-count/>
>         <nlt-count/>
>         <tev-count/>
>         <niv-references>EXO 6:12,30 JOB 4:4</niv-references>
>         <nasb-references/>
>         <nlt-references/>
>         <tev-references/>
> </word-group>
> <word-group>
>         <word>falters</word>
>         <master-count/>
>         <master-number/>
>         <master-name/>
>         <niv-count>1</niv-count>
>         <nasb-count/>
>         <nlt-count/>
>         <tev-count/>
>         <niv-references>ISA 21:4</niv-references>
>         <nasb-references/>
>         <nlt-references/>
>         <tev-references/>
> </word-group>
> 
> 
> Jim Albright
> 704 843-0582
> Wycliffe Bible Translators

Current Thread