Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 15th, 2003, 12:08 PM
Registered User
 
Join Date: Dec 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Explanation asked about XSL/XPath expression

I've used the following line in one of my xsl-documents (for an assignment for school), and it does exactly what it was ment to do... but....

My teacher asked if i could explain it for the class tomorrow, and i don't know how... :) Can someone help me with a description of what the following line exactly does? :)

Code:
<xsl:for-each select="//recepy[generate-id(.)=generate-id(key('book',author))]">
Thanks in advance!!!! ;)



 
Old December 15th, 2003, 01:39 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

I'm guessing here because you haven't shown us what your xml looks like, but presumably you have defined a key called 'book' which groups all nodes (recepy nodes?) by a common author child node.

So, the construct key('book',author) returns all (recepy?) nodes which have the same author as the current recepy node. Then generate-id does exactly what it says for the first node in that set.

generate-id(nodeX)= generate-id(nodeY) is a generic way of determining if the two nodes nodeX and nodeY are the same node. So you end up with a set containing one recepy node for each unique author node.

There's a very good explanation of this construct and its use in grouping here:
http://www.jenitennison.com/xslt/gro...muenchian.html

hth - post your XML and XSLT if you it still doesn't make sense.
Phil
 
Old December 15th, 2003, 06:29 PM
Registered User
 
Join Date: Dec 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Phil!

Thank you very much! I already knew what the code's function was, and a bit about what it 'really' did. But your explanation is very useful for my class tomorrow thank you very much!

And i'll remember to put more relevant code in my post next time, your assumptions were right, luckily for me ;)






Similar Threads
Thread Thread Starter Forum Replies Last Post
XPath 2.0 every expression stolte XSLT 5 November 24th, 2008 03:32 PM
String xsl:param as XPath expression Vx XSLT 4 September 5th, 2006 10:18 AM
XPath Expression NEO1976 XSLT 11 August 2nd, 2006 02:28 AM
Need help with XPATH Expression benomathew XSLT 1 May 12th, 2006 04:41 AM
Need help with XPATH Expression benomathew XML 1 May 9th, 2006 03:38 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.