At 2008-11-26 21:33 +0100, Christoph LANGE wrote:
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?
Because there is no current node.
When you have "//@xml:id" that is saying in effect "from the root of
the node tree of the current node find all xml:id attributes" ...
since this is in a predicate on a sequence of strings, there is no
node tree of the current node because the context item is a string not a node.
You probably want something like:
<xsl:variable name="tree" select="/"/>
<xsl:for-each select="$string-sequence[.=$tree//@xml:id]">
...
Or would this work even better for you:
<xsl:for-each select="//@xml:id[.=$string-sequence]">
...
I hope this helps.
. . . . . . . Ken
--
Upcoming XSLT/XSL-FO, UBL and code list hands-on training classes:
: Sydney, AU 2009-01/02; Brussels, BE 2009-03; Prague, CZ 2009-03
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video sample lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg
Video course overview: http://www.youtube.com/watch?v=VTiodiij6gE
G. Ken Holman mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
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
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--