Subject: [xsl] one node from multiple docs From: Matt Lewis <mlewis@xxxxxxxxxxxxxxxxxxx> Date: Wed, 06 Feb 2002 09:08:31 -0500 |
I've just started learning XSL, am making a sample project, and am having difficulty understanding how to select a single instance of a node that appears in multiple documents. I have several "project" documents, each of which lists the "participants" involved with that project. I'm using the "Grouping Across Multiple Documents" technique from Doug Tidwell's XSLT book to produce a page containing the name of each participant followed by a list of the projects they are involved with. What I would now like to do is, given a name of a participant, look through the project documents and find just one of the PERSON nodes matching their name so I can collect and use the other info in the PERSON node (e.g. URL or EMAIL elements.) The problem: I have no trouble finding ALL of the nodes corresponding to this person in all of the documents... I'm just not sure how to refer to only one of them in the resulting node set. If I do something like: <xsl:variable name="person" select="document($rtopics/descendant::rtopic/@url)/*/PARTICIPANTS/PERSON[NAME/LAST=$next-name]" /> I think this gives me a node set containing all of the PERSON nodes with the desired last name (assume unique last names for the moment...) I'd like to now say something like: <DL><DT><xsl:apply-templates select="$person[0]" /></DT> or <DL><DT><xsl:apply-templates select="$person[last()=1]" /></DT> or somesuch to get just one of the nodes. But if the person is involved with five projects, then I get their name five times. When I try to use any of the techniques I can find for only choosing the "first" or "last" node selected, I think I'm still having problems because (if I understand correctly) each selected node passes my tests because it is the one and only node selected, relative to the root node of each separate document. Any suggestions for how I can say, "of the five (identical) nodes that were found in five different documents just let me pass one of them to apply-templates"? My fallback I suppose would be to pack up all the person's info in a string when I first collect all the names and remove duplicates, and then pick apart the string when I want to display their info, but that seems kind of inflexible and cumbersome... hoping there's a better way! (I'm in Digest mode, would welcome a cc'd direct reply) Thanks. -Matt -- Matthew Lewis mlewis@xxxxxxxxxxxxxxxxxxx http://www.cgrg.ohio-state.edu/~mlewis Advanced Computing Center for the Arts and Design Ohio State University "What's he BUILDING in there?!?" -Tom Waits XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XSL-HTML Table problem, Joerg Pietschmann | Thread | Re: [xsl] one node from multiple do, Jeni Tennison |
Re: [xsl] XSL-HTML Table problem, Joerg Pietschmann | Date | RE: [xsl] Trouble with grouping, David B. Bitton |
Month |