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

RE: Filtering sequences of atomic types

Subject: RE: Filtering sequences of atomic types
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 26 Nov 2008 20:43:43 -0000
RE:  Filtering sequences of atomic types
An expression that starts with "/" selects nodes within the current
document, that is, the document that contains the context node. If there is
no context node, that is, if the context item is an atomic value, then
there's no current document and the system doesn't know which document you
want to search.

So you have to bind a variable to the document outside the predicate, for

<xsl:variable name="doc" select="/"/>

and then you can do $string-sequence[. = $doc//@xml:id]

Converting the strings to text nodes will get rid of the type error, but it
won't solve the problem, because //@xml:id will only look in the document
that contains the text node being tested.

Michael Kay

> -----Original Message-----
> From: Christoph LANGE [mailto:ch.lange@xxxxxxxxxxxxxxxxxxxx] 
> Sent: 26 November 2008 20:34
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Filtering sequences of atomic types
> Dear all,
>   I'm trying to filter a sequence using a predicate that 
> involves a node set.
> What I actually want to do is something like
> $string-sequence[. = //@xml:id]
> i.e. get all items of a sequence that occur as an xml:id 
> attribute somewhere in the document.
> As that gives me the error message "XPTY0020: Cannot select a 
> node here: the context item is an atomic value" (with Saxon 
> 9.1), I tried
> $string-sequence[. = (for $n in (//@xml:id) return xs:string($n))]
> or even
> ('foo', 'bar')[. = (for $n in (//@name) return 'foo')]
> where the latter should actually return something like 
> ('foo', 'foo', ...), and ('foo', 'bar')[. = ('foo', 'foo')] 
> works, of course.
> My current workaround is translating the string sequence to a 
> sequence of text nodes, but why doesn't it work with a 
> sequence of atomic types?
> Thanks for any help,
> Christoph
> --
> Christoph Lange, Jacobs Univ. Bremen, 
> http://kwarc.info/clange, Skype duke4701

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.