xsl-list
[Top] [All Lists]

RE: [xsl] Ordering "roles"

2006-08-16 09:05:42
The usual form of this problem is that the data forms a tree, then the
standard approach is to identify the root, apply-templates to it, and in
this template do an apply-templates on its logical children, found using an
expression such as:

select="//role[hasroles/include = current()/name]"

(though it's easier and more efficient to use keys).

If you need to look for cycles in the data, then it's a bit more difficult.

In your case it seems the data is not necessarily a tree, but an acyclic
graph. I think you can use essentially the same approach except that you
have to eliminate duplicates caused by reaching the same node by more than
one route. I'll have to delve into a dusty book on graph algorithms for that
one...

Michael Kay
http://www.saxonica.com/


-----Original Message-----
From: Phillip B Oldham [mailto:phillip(_dot_)oldham(_at_)kilo75(_dot_)com] 
Sent: 16 August 2006 16:07
To: Mailing List: XSL
Subject: [xsl] Ordering "roles"

Hi guys

I've got some xml in the following structure:

<roles>
    <role>
       <name>Create</name>
       <hasroles />
    </role>
    <role>
       <name>Approve</name>
       <hasroles>
          <include>Create</include>
          <include>Edit</include>
       </hasroles>
    </role>
    <role>
       <name>Edit</name>
       <hasroles>
          <include>Create</include>
       </hasroles>
    </role>
</roles>

So from this we can see that if your role is Edit, you can 
also Create.

I need to produce an ordered list which takes into account 
the above statement, such as:

<ul>
    <li>Create</li>
    <li>Edit</li>
    <li>Approve</li>
</ul>

Approve coming last in the list because it "includes" the 
above two, Edit below that because it "includes" Create, and so on.

I'm using XSL1 with EXSLT.

Any ideas on how I can accomplish my goals?

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>