Re: [xsl] Using absolute path when context item is an atomic value xslt 2.0

Subject: Re: [xsl] Using absolute path when context item is an atomic value xslt 2.0
From: andrew welch <andrew.j.welch@xxxxxxxxx>
Date: Tue, 18 Oct 2005 18:07:35 +0100
>     andrew> This seems cumbersome, so I'm probably not using "1 to 10"
>     andrew> in the correct way.
>
> It depends upon what you are trying to do. As far as I can see, your
> [.] could be replaced by [position < 11], and then you wouldn't need
> the 1 to 10 at all.
> But maybe I'm misunderstanding your intention.

It's just an example to demonstrate what happens when the context is
an atomic value.

>     andrew> Actually, I can't see why '/' would ever select anything
>     andrew> when the context item is an atomic value, so why doesn't
>     andrew> it keep it's pointer to the original root.
>
> Suppose there WASN'T an original root? There is no requirement in XSLT
> 2.0 for there ever to be a document root.
> How do you define "original"?

If it did what it usually does when context is an actual node (even if
its from a rootless tree) - when the context is an atomic value its an
error to try and select any nodes at all, which is strange because you
would expect the two could co-exist happily.

As I say, I haven't spent much time processing atomic values yet so my
expectations might be off, but I think it's intuitive that:

<xsl:template match="node">
  <xsl:for-each select="1 to 10">
    <xsl:apply-templates/>

would apply-templates to <node> 10 times.  This isn't possible because
the context node is an atomic value and of course it makes no sense to
apply-templates that, so it's an error.

As Mike said in another reply, they thought about having a context
document that would remain when the context item was an atomic value -
which makes most sense to me - but it was dropped so the alternative
is to recreate that with variables.

The concept of the context "node" being an atomic value adds quite a
bit to the learning curve...

Current Thread