[Home] [By Thread] [By Date] [Recent Entries]
At 2009-02-11 14:44 +0100, Felix Nensa wrote:
I have a weird problem where the "except" operator does not behave as I would expect it. You are incorrectly treating "except" with node values, instead of as node identity. Given the following input source XML: The expression: $A except $B ... will give you those nodes in $A that are not also nodes in $B. Not the values of the nodes, but the nodes themselves. I am using the latest version of Saxon. Always a wise choice! You want to deal with node value by using the "=" operator ... I have an example below. Checking a scalar against the set returns false when the operator is false for all members of the set, or true when the operator is true for any member of the set. I hope this helps. . . . . . . . Ken T:\ftemp>type felix.xml
<root>
<Response>
<Users>
<Count>2</Count>
<User>
<Username>henry</Username>
<Online>false</Online>
<UserId>302</UserId>
</User>
<User>
<Username>felix</Username>
<Online>false </Online>
<UserId>288</UserId>
</User>
</Users>
</Response>
<Response>
<Friends>
<Count>1</Count>
<Friend>
<UserId>288</UserId>
</Friend>
</Friends>
</Response>
</root>T:\ftemp>type felix.xsl
<?xml version="1.0" encoding="US-ASCII"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0"><xsl:output method="text"/> <xsl:template match="/"> <xsl:variable name="users" select="//Users/User/UserId" /> <xsl:variable name="friends" select="//Friends/Friend/UserId" /> <!-- debug output --> <xsl:value-of select="$users [. != $friends]" /> </xsl:template> </xsl:stylesheet> T:\ftemp>xslt2 felix.xml felix.xsl 302 T:\ftemp> -- Upcoming hands-on XSLT, UBL & code list hands-on training classes: Brussels, BE 2009-03; Prague, CZ 2009-03, http://www.xmlprague.cz Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18 Video overview: http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18 G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
|

Cart



