Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Re: Querying an Active Directory memberOf Attribute

From: Wendell Piez <wapiez@---------------->
To:
Date: 8/2/2006 3:20:00 PM
At 10:27 AM 8/2/2006, it was written:
As for using a node set as a kind of array and checking for the
existence of the desired substring in the text value of each node (in
this case, the equivalent of an array element), you need a mechanism
to cicle through all the nodes in the node set (all the "elements" in
the "array"). Otherwise, only the first node will be checked.


To do that, you'll need a recursive template...

Given a nodeset, in simpler cases one can ask for



$nodeset[contains(.,$string)]



to return any (all) members of $nodeset that contain a substring 
$string. This subset coerces to Boolean true when it has any members, 
so one can say



<xsl:when test="$nodeset[contains(.,$string)]">...</xsl:when>



and get the desired behavior. (And indeed one can inspect this subset 
to see what members it has, etc.)



Erik is correct that in more complex cases one has to resort to 
recursion. Because it is so cumbersome, however (relatively), and 
because simple string equivalence testing is so easy, another 
approach is simply to design around this problem. As Mike pointed out,



$nodesetA = $stringB



if *any* node in $nodesetA has string value $stringB.



Ordinarily I don't recommend "designing around problems", but 
conversely, it's also true that a good design is good precisely 
because it tends to avoid such problems. XSLT 1.0 was not built to 
support arbitrary queries over XML or even arbitrary transformations 
-- we were supposed to have XQuery for that, as indeed we will, and 
XSLT 2.0 along with it.



If confined to XSLT 1.0, one conceivable solution, accordingly, is to 
preprocess your input in such a way that the values you are looking 
for are normalized as single strings, and substring analysis (not the 
language's strength) is therefore avoided.



Another approach is to look to Dimitre's work with FXSL, which by 
taking advantage of quasi-functional features in XSLT (when it is 
permitted to process its own results with an extension function in 
1.0) abstracts many such problems away, at the cost of mastering its concepts.



Cheers,
Wendell


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent