RE: [xsl] Muenchian method, and keys 'n stuff

Subject: RE: [xsl] Muenchian method, and keys 'n stuff
From: DPawson@xxxxxxxxxxx
Date: Wed, 23 Jan 2002 09:55:47 -0000
> > Out of 2200 books, that's highly likely, though the scoping of
> > 'within adventure' makes it not true for this scope.
> 
> Sure, but the code doesn't look just in the adventure, so it would
> explain why you were never hitting the 'otherwise'.

I twigged that, through debug I found out that it was from the scifi
section :-)

> 
> To be more explicit about the solution I was suggesting for that -
> make the key include the ID for the adventure as well as the Ra/lett:
> 
> <xsl:key name="auth" match="adventure/r"
>          use="concat(generate-id(..), ' ', Ra/lett)" />
> 
> The key values here are combinations of the ID of the adventure and
> the letter that the author's name starts with. I used a space between
> them as a separator, but you could use anything that isn't allowed in
> an ID.

I did try that, without results,
though I didn't have a seperator. Is that essential?

> 
> You're passing through the ID of the adventure through the $section
> parameter, so you can use this while creating the list of $auths:
> 
>   <xsl:variable name="auths"
>     select="key('auth', concat($section, ' ', $letter))" />
> 
> That guarantees that the only r elements that you get hold of from the
> key are those within the adventure whose ID you passed through from
> the calling template. So now the $auths variable holds a node set of r
> elements, within the adventure that you're looking at, whose Ra/lett
> starts with the letter $letter.

OK.

> 
> Now, I'm not sure why you're trying to pick out only the first book
> with a particular letter within that section. That would be something
> that you'd need to do if you wanted to collect together the letters
> that start the books in that section. But by the time you're within
> the when, you *know* that the letter that you're currently on
> ($letter) is a letter that is present in one or more rs in this
> adventure. I doubt that you explicitly need to get hold of the first
> auth with that letter, but if you do, then you can just use:
> 
>   $auths[1]

Duh! To quote Norm Walsh :-)

I want something like

'Adventure'
  Adrews, Fred
   All books by Andrews, Fred
  Axminster, Joe
   All books by him (no author)

Hence the find the first, process the rest as following-siblings::r
method.


> 
> I think that you probably want to have a heading saying what letter
> you're on, followed by a list of the r elements that you've gathered
> together from that adventure with that letter as their Ra/lett. So
> within the xsl:when you want something like:
> 
>   <h2>
>     The letter <xsl:value-of select="translate($letter, $l, $u)" />
>   </h2>
>   <xsl:for-each select="$auths">
>     <h3><xsl:value-of select="Ra/auth" /></h3>
>   </xsl:for-each>
> 
> This is basically what you had in your original code (and is what I
> suggested in the first solution that I sent).

sorry Jeni. I was simplifying. Each r entry holds
<r><cat-num>721</cat-num><TBcategory/><play-time>11:45</play-time><wng/><rea
ders>Clive Champney</readers><m100>
         <surname>Pape</surname>
         <f-name>Richard</f-name>
      </m100><m245>
         <ttl>Boldness be my friend</ttl>
      </m245><m700/><m513>Shot down over Germany, Pape endured torture and
hardship in Gestapo prisons, from which he finally
escaped.</m513><Ra><lett>p</lett><au>Pape, Richard. </au></Ra></r>

And I need to print out most of it. Its a catalog of talking books.


> 
> > Strange, that keys have been given only the current document as
> > scope, I can't use them across n documents, I can't use them in a
> > section of a document... I'm sure there are other use cases for
> > limited scope keys. Feature for consideration for 2.0?
> 
> It does seem to be a very popular use. I should think that most of the
> utility comes when using the Muenchian grouping method. But the above
> case (which doesn't really use Muenchian grouping, because you *know*
> what groups you're after) illustrates that it's useful elsewhere.

I chose it to get the first, rest style of processing.

What do you think of extending the use of keys to a specific scope?

Regards DaveP

- 

NOTICE: The information contained in this email and any attachments is 
confidential and may be legally privileged. If you are not the 
intended recipient you are hereby notified that you must not use, 
disclose, distribute, copy, print or rely on this email's content. If 
you are not the intended recipient, please notify the sender 
immediately and then delete the email and any attachments from your 
system.

RNIB has made strenuous efforts to ensure that emails and any 
attachments generated by its staff are free from viruses. However, it 
cannot accept any responsibility for any viruses which are 
transmitted. We therefore recommend you scan all attachments.

Please note that the statements and views expressed in this email 
and any attachments are those of the author and do not necessarily 
represent those of RNIB.

RNIB Registered Charity Number: 226227

Website: http://www.rnib.org.uk 


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


Current Thread