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

determining if 2 sequences of strings intersect

Subject: determining if 2 sequences of strings intersect
From: Robert Koberg <rob@xxxxxxxxxx>
Date: Fri, 26 Jun 2009 14:13:14 -0700
 determining if 2 sequences of strings intersect

Is there an easy way to determine whether 2 sequences of xs:string+ intersect. I am not able to use:

$seq1 intersect $seq2

because they need to be nodes.

An example with my lame(?) solution at the bottom:

I have a sequence of 'role' elements, e.g.

 <dbo.ROLE USER_ID="19955" ROLE="CAEMP"/>
 <dbo.ROLE USER_ID="19955" ROLE="INCPL"/>
 <dbo.ROLE USER_ID="19955" ROLE="MNGR"/>
 <dbo.ROLE USER_ID="19955" ROLE="NewHire"/>
 <dbo.ROLE USER_ID="19955" ROLE="NONHIEMP"/>
 <dbo.ROLE USER_ID="19955" ROLE="VEHALLW"/>

which is converted to a sequence of xs:string by:

<xsl:with-param name="roles"
 select="for $r in $roles return string($r/@ROLE)"

and I have an attribute that identifies role restrictions in another document context, e.g.

<task roleRestrictions="CAEMP VEHALLW"/>

which is converted to a sequence by:

<xsl:variable name="restrictions"
 select="tokenize(@roleRestrictions, ' ')"

So, what I am doing to get a value to show as true or false in a table cell is:

select="not(empty(index-of(f:has-role($roles, $restrictions), true())))"/>


 <xsl:function name="f:has-role" as="xs:boolean+">
   <xsl:param name="roles" as="xs:string+"/>
   <xsl:param name="restrictions" as="xs:string+"/>
   <xsl:sequence select="for $r in $restrictions return
     if (index-of($roles, $r)) then true() else false()"/>

Is there a better way?


Current Thread


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.
First Name
Last Name
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.