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

Re: 'except' operator on atomic integer values

Subject: Re: 'except' operator on atomic integer values
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 24 Dec 2007 07:26:23 -0500
Re:  'except' operator on atomic integer values
At 2007-12-24 15:14 +0530, Mukul Gandhi wrote:
   I am trying to use the 'except' operator (to calculate set
difference) in a XSLT 2.0 stylesheet (using Saxon 9-b). My attempt is
below:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                         version="2.0">

<xsl:output method="text" />

 <xsl:template match="">
   <xsl:variable name="seq1" select="(1,2,3)" />
   <xsl:variable name="seq2" select="(1,2)" />

<xsl:value-of select="$seq1 except $seq2" />

</xsl:template>

</xsl:stylesheet>

The sets (sequences) will contain atomic integer values (the values
are not nodes). The above stylesheet is giving error:
XPTY0004: Required item type of first operand of 'except' is node();
supplied value has item type xs:integer

Is it possible to cast atomic values like integers above to a suitable
node, so that except operator works on such data ?

Not that I know of ... the except operator works on the *identity* of nodes in the tree, so in order to get a match on like values you would have to somehow create the same nodes for the same values.


But since you want to use values, why not go with your original idea of just comparing values?

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                         version="2.0">

<xsl:output method="text" />

 <xsl:template match="/">
   <xsl:variable name="seq1" select="(1,2,3)" />
   <xsl:variable name="seq2" select="(1,2)" />

<xsl:value-of select="$seq1[not(. = $seq2)]" />

</xsl:template>

</xsl:stylesheet>

My earlier warning when you asked about the "except" operator was that your proposal was using values instead of identity ... since atomic values don't have identity, you'll want to use values. Your earlier example didn't distinguish the use of atomic values.

I hope this helps.

. . . . . . . . . . . . . Ken

--
Comprehensive in-depth XSLT2/XSL-FO1.1 classes: Austin TX,Jan-2008
World-wide corporate, govt. & user group XML, XSL and UBL training
RSS feeds:     publicly-available developer resources and training
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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