Subject: Re: [xsl] variable question From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Thu, 11 Nov 2004 20:41:56 +0000 |
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)"> <mods:mods>...</mods:mods> </xsl:variable> 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. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] variable question, David Carlisle | Thread | Re: [xsl] variable question, Geert Josten |
Re: [xsl] variable question, Bruce D'Arcus | Date | Re: [xsl] characters in xsl, Geert Josten |
Month |