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

Re: variable question

Subject: Re: variable question
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Thu, 11 Nov 2004 20:41:56 +0000
concat function xsl
Hi Bruce,

> On Nov 10, 2004, at 5:00 PM, Jeni Tennison wrote:
>> Note that the path "$bibrecord/key('biblio', $bibkey)" is newly
>> allowed in XPath 2.0, and makes searching documents using keys a whole
>> lot easier than it used to be.
> Ah, that's what I'm looking for.
> I'm getting this error though:
>         A sequence of more than one item is not allowed as the second argument
> of concat()     
> Here's how I've defined the top-level variables:
>     <xsl:variable name="bibkey" select="//db:biblioref/@linkend" />
>     <xsl:variable name="bibrecord" select="doc(concat('bib-data/', 
> $bibkey, '.mods'))" />
>     <xsl:key name="biblio" match="//mods:mods" use="@ID" />
> Why am I getting that error then?

...because the second argument to the concat() function is a sequence
of more than one item -- a sequence of all the linkend attributes of
all the <db:biblioref> elements in the source document, to be precise.
The arguments to the concat() function (in XPath 2.0) must all be
single items.

Looking again, I'm confused about what you're trying to do. Do you
want $bibrecord to hold a sequence of all the documents whose paths
are bib-data/X.mods where X is the value of the linkend of a
<biblioref> within your document?

If so, you need:

<xsl:variable name="bibrecord"
  select="$bibkey/doc(concat('bib-data/', ., '.mods'))" />

and I don't see how the key fits into it.

By the way, in the key definition, the match pattern shouldn't have
the "//" at the beginning. In XSLT 1.0, it never makes sense to use
"//" at the beginning of a pattern, because it just adds the test that
the matched node must appear in a document, and of course all nodes
appear in a document. In XSLT 2.0, the patterns "//mods:mods" and
"mods:mods" are different: the latter matches all <mods:mods> elements
while the former only matches <mods:mods> elements that appear within
a tree whose root is a document node. For example, it wouldn't match
the <mods:mods> element held by $mods in:

<xsl:variable name="mods" as="element(mods:mods)">

because in this case the <mods:mods> element is parentless. This
distinction is very subtle, and usually unimportant, but in general my
advice would be to avoid the "//" at the beginning of the pattern
unless you're really sure that you'll never want to match elements
that don't appear in a tree rooted with a document node.



Jeni Tennison

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.