Re: Sort problem
Hi Mick, Dimitre wrote: > The xsl:sort element in the previous stylesheet must be modified to the > following: > > <xsl:sort > select="translate(concat(.,self::*[contains(.,'')] ^^ > /following::word[@type='end']), '-', '')"/> but meant: <xsl:sort select="translate(concat(.,self::*[contains(.,'-')] ^^^ /following::word[@type='end']), '-', '')" /> Brilliantly insightful solution. Just to explain why the stuff I wrote used lots of substring() and string-length() all over the place: I was assuming that there might be words that contained hyphens in the middle of them. For example: <word>ABC-</word> <word>spirit-level</word> <word type="end">DEF</word> should presumably be output/sorted as: ABCDEF spirit-level rather than: ABCDEF spiritDEF Of course it might not be a problem with the input that you're using, but if it is, then you need to substitute: contains(., '-') -> substring(., string-length()) = '-' string-before(., '-') -> substring(., 1, string-length() - 1) and of course using the translate() function will get rid of *all* the hyphens in the words, which may or may not be helpful. The safest solution is probably: concat(substring(., 1, string-length() - 1), substring(self::node()[substring(., string-length()) != '-'], string-length()), self::node()[substring(., string-length()) = '-'] /following::word[@type = 'end']) But of course you should use the simplest that you can get away with. I hope that helps, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format