Re: [xsl] document() path relative to current document

Subject: Re: [xsl] document() path relative to current document
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 23 Nov 2004 21:55:13 +0000
Hi Robert,

> I believe that you and David are right, BUT how can I make the value of an
> attribute @href a node-set?
>
> I have <a href="folder/foo.html"> and want to read data from that external
> file. I save the url to a variable by using <xsl:variable name="bar"
> select="@href"/>. So $bar is still just a string.
> select="@href"/> When I provide this to the
> document function by document($bar,/) i suppose it will not magically become
> a nodeset.

You're missing the point. An XPath location path such as "foo/bar",
"//baz" or "@href" returns a node-set. In some circumstances, that
node-set might get converted to a string, for example when you
use it as one of the arguments to the concat() function, but if you
set a variable like:

  <xsl:variable name="bar" select="@href" />

then the value of the $bar variable is a node-set. The node-set
held by the $bar variable contains a single node: the href attribute
of the current node. The $bar variable does not contain a string. (I
say this repeatedly in as many ways as I can just to drum it in.)

When you provide it to the document function as in:

  document($bar)

the argument to the document() function is a node-set, not a string.
Therefore it should work in exactly the way that David and Mike have
told you it should work. If it doesn't work in that way, you need to
start looking for other reasons why not.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Current Thread