|
Subject: Re: [xsl] Problem with "except" operator From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Wed, 11 Feb 2009 08:48:55 -0500 |
I have a weird problem where the "except" operator does not behave as I would expect it.
Given the following input source 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> </GetUserList> </Response> <Response> <Friends> <Count>1</Count> <Friend> <UserId>288</UserId> </Friend> </Friends> </Response> </root>
I am trying to get all those Users wich are not in the list of Friends with the following expression:
<xsl:variable name="users" select="//Users/User/UserId" /> <xsl:variable name="friends" select="//Friends/Friend/UserId" />
<!-- debug output --> <xsl:value-of select="$users except $friends" />
It outputs: 302 288 I would expect: 302
I am using the latest version of Saxon.
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: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
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Problem with "except" ope, Andrew Welch | Thread | Re: [xsl] Problem with "except" ope, Felix Nensa |
| Re: [xsl] Problem with "except" ope, Andrew Welch | Date | Re: [xsl] Problem with "except" ope, Felix Nensa |
| Month |