xsl-list
[Top] [All Lists]

Re: [xsl] xpath key problems

2010-11-21 12:42:26
Birnbaum, David J wrote:

     <!-- Two problems, the first of which is fatal:
         1. Doesn't work; key returns nothing
             Change @use to "." and it returns the current element
             Change @use to any function (e.g., string-length(.) or name(.)) 
and it returns nothing (?)
             Same results with . or current() or self::node() or nothing; does 
the choice matter here?
         2. Very slow
             Is this inevitable with the long axes or can it be optimized 
(Saxon HE 9.2.1.2)?
             Likely to get *much* slower when we also count lines (see below)
     -->
     <!-- desired result: @folio value for most immediately preceding<pb>  in 
same ms (specific hm28x)
         1. get all preceding<pb>  elements
         2. restrict the set to those in the same ms
         3. take the last (immediately preceding) one of those
     -->
     <!-- interim simplifications
         Must handle first page of each ms specially, since there is no 
preceding<pb>
         Contents of each ms line requires additional templates
         Eventually must also count<lb>  elements between that most recent 
preceding<pb>  and current location;
             full pointer will be something like 312r14, where 312r is the page 
and 14 is the line on the page
     -->
     <xsl:key name="msline-pb" match="hm281 | hm280 | hm282"
         use="preceding::pb[parent::*/name() eq name()][1]/@folio"/>

You might want
use="preceding::pb[parent::*/name() eq name(current())][1]/@folio" to define your key but I am not sure I understand what you want to do with the key as


     <xsl:template match="hm281 | hm280 | hm282">

             <pointer>
                 <xsl:value-of select="key('msline-pb',.)"/>

this passes the contents of the 'hm28x' elements to the key function while above you define the value as something like '282r'. The contents seems to be text like 'в лѣто. ҂е҃ ѡ҃ г҃. ' so I don't see what you want to do with that key.


--

        Martin Honnen
        http://msmvps.com/blogs/martin_honnen/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>