|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: One nodeset, multiple branches
Eric,
You have the problem half solved. It's not really an XPath thing, exactly; it's in having to establish a relation between each <group> that contains <right> descendants, with the users assigned to that group. As you have seen, user[@username='evitiello]/rights/right (or, more comprehensively but less efficiently, user[@username='evitiello]//right) will get the user's own 'proper' rights (when the user is you :-). To get the rights associated with groups assigned to the user, is of course a bit trickier. First: <xsl:variable name="usergroups" select="user[@username='evitiello']//group/@name"/> Gets the @name attributes on the groups belonging to your user (you) into a variable. Then, get rights associated with these groups: //group[@name=$usergroups]//right (Again, this is comprehensive but not maximally efficient for your case.) This relies on the fact that a node-set (here, a group/@name) is equal to another node-set (here, your variable, a collection of names) if any node in one node-set has a string value equal to any node in the other. Combining these two XPaths does everything you need except de-duplicating the list. To do that, I'm afraid you'll have to iterate over the node-sets and check each node's preceding:: or following:: axis. This will get expensive if your data set is large. Another approach, potentially much more efficient, is to use keys ... and that will let you de-duplicate as well (maybe I'll tackle that later if Jeni doesn't first ;-). I don't think this XPath is over your head; it's just a bit hard to see around corners until you learn to use other features of the language (node-sets bound to variables; keys) as mirrors. Cheers, Wendell At 09:22 AM 12/19/01, you wrote: Hi. ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ====================================================================== 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
|

Cart








