[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] One nodeset, multiple branches


Subject: [xsl] One nodeset, multiple branches
From: Eric Vitiello <xsl-list@xxxxxxxxxxxx>
Date: Wed, 19 Dec 2001 09:22:49 -0500

Hi.

I have the following XML:

<?xml version="1.0"?>
<access>
        <users>
                <user username="evitiello">
                        <realName>Eric Vitiello</realName>
                        <rights>
                                <right module="news" access="add"/>
                                <right module="page" access="edit"/>
                        </rights>
                        <userGroups>
                                <group name="administrators"/>
                        </userGroups>
                </user>
        </users>
        <groups>
                <group name="marketing">
                        <rights>
                                <right module="news" access="add"/>
                        </rights>
                </group>
                <group name="administrators">
                        <rights>
                                <right module="news" access="add"/>
                                <right module="news" access="edit"/>
                                <right module="news" access="delete"/>
                                <right module="page" access="add"/>
                        </rights>                
                </group>
        </groups>
</access>

I would like to be able to return a nodeset that contains all of the "rights" that a given user has.

This gets complicated, because it's not simply user[@username='evitiello]/rights/right to get the user's 
rights... I also need to find out what rights they have for the groups they are in.  For example, evitiello is in 
the "administrators" group, so he should also have all the rights listed under the node for 
/groups/group[@name='administrators'].

Therefore, getting the rights for evitiello should return:

                                <right module="news" access="add"/>
                                <right module="page" access="edit"/>
                                <right module="news" access="add"/>
                                <right module="news" access="edit"/>
                                <right module="news" access="delete"/>
                                <right module="page" access="add"/>

Also notice that the <right module="news" access="add"/> node is duplicated because the user itself has the 
right, as well as the group they are in.  I would rather it only return one instance of this right.  The XPath 
should also be able to handle a user that is in multiple groups.

Either this xpath is out of my league, or I'm missing something very simple.

Thanks,

---
Eric Vitiello
Perceive Designs
<www.perceive.net>;


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread
Keywords