[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: glossary sorting/indexing question

Subject: Re: glossary sorting/indexing question
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 20 May 2008 13:02:20 +0100
Re:  glossary sorting/indexing question
> <!DOCTYPE xsl:stylesheet [<!ENTITY nbsp "&#160;">]>
personally I wouldn't bother, #160 isn't any harder to type than nbsp,
and having the doctype there can cause problems with some systems, which
use it as a hint to request stylesheet validation, thus generating an
error on every element as this dtd doesn't define any elements.



<!-- subhead key -->
<xsl:key name="subhead" match="/document/section"
use="translate(substring(./title,1,1),$lochars,$upchars)" />


This is an XSLT2 feature, XSLT 1.0 does not allow variables in key
definitions. If you are using xslt2 though it's simpler to get rid of
the variables and use

<!-- subhead key -->
<xsl:key name="subhead" match="/document/section"
         use="upper-case(substring(title,1,1))" />

(you never need to start an xpath with ./)

similarly of course you can use upper-case in the key() function, but...

> count(. |
> key('subhead',translate(substring(./title,1,1),$lochars,$upchars))[1])

This is muenchian grouping, and is much more simply expressed in xslt2 using

<xsl:for-each-group select="/document/section"
group-by="upper-case(substring(title,1,1))">

then to access the members of the group, replace
"key('subhead',$initial) by current-group()

so... I think your stylesheet would be fine as an example of muenchian
grouping in xslt 1 if you made the key definition legal by getting rid
of the variable references:

<xsl:key name="subhead" match="/document/section"
use="translate(substring(./title,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ)" />


but in xslt2 such idiomatic uses of muenchian grouping can more or less
automatically be converted to xsl:for-each-group, which probably doesn't
make much difference to the way the generated code runs, but makes it
rather more readable.


David


________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 
________________________________________________________________________

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.