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

one node from multiple docs

Subject: one node from multiple docs
From: Matt Lewis <mlewis@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 06 Feb 2002 09:08:31 -0500
matt lewis
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

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.