Subject: Re: [xsl] Interpretaion of grouping for-each From: David Carlisle <davidc@xxxxxxxxx> Date: Tue, 4 Nov 2003 11:06:26 GMT |
> What does count() =1 represent (got a bit confused about jeni's > explanation) No, that's the wrong way round. The usual pattern is that I give the confusing (or at least terse) explanation and Jeni explains it. > count(. | .....) =1 XSLT 1 does not have a test for node identity, you can use = to test if one node has the same value as another but not whether it actually is the same node. You have an expression ...... (actually viewentry{key('ve-by-firstocc', substring(entrydata[3]/text,1,1))[1]] ) that returns a node, and you want to know if that node is the current node, not just if it has the same character data, there are two methods to test that in xslt 1 (in Xpath 2 you could just use . is viewentry{key('ve-by-firstocc', substring(entrydata[3]/text,1,1))[1]] ) as the is operator tests node identity. however in xslt 1 you use the set union method: (. | .....) is a set of nodes being the union of the current node (.) and the other one (....) so either there is one node in this set (if . and ..... are the same) or 2 nodes (if they are different) so testing count()=1 will determine this identity. The other method (which is the one I tend to use as it's slightly clearer I think) is to test generate-id(.) = generate-id(.....) as generate-id will return an id string taht is unique to each node, so testing these strings will test identity. note in the above "." means "." bit "...." is a meta placeholder for the expression of interest (key('ve-by-firstocc', substring(entrydata[3]/text,1,1))[1]]" in your case) Just to be clear, am i right in saying that "viewentry{key('ve-by-firstocc', substring(entrydata[3]/text,1,1))[1]]" selects the first of each group of viewentries with the same key (including groups which only have one viewentry in it)? Yes. David -- http://www.dcarlisle.demon.co.uk/matthew ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Interpretaion of grouping, james walker | Thread | Re: [xsl] Interpretaion of grouping, james walker |
Re: [xsl] embedded php in xslt, Michael Olszynski | Date | Re: [xsl] embedded php in xslt, David Carlisle |
Month |