Re: [xsl] How to specify a path to a node in a nodeset using a variable

Subject: Re: [xsl] How to specify a path to a node in a nodeset using a variable
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Wed, 14 Mar 2001 08:56:12 +0000
Hi Shakeel,

> I tried it and it works!!! But it is a mystery what exactly is
> saxon:evaluate() doing?

saxon:evaluate() takes a string that is an XPath expression and
evaluates it, returning the result of the expression.

> It receives the following argument $container//account/person/@name
> because of the concat function.
>
> concat('$container/', $path) where $path is /account/person/@name
>
> Is $container//account/person/@name a valid XPath expression?

Yes.  It says:

  get all the nodes in the $container variable
    get all their account element descendants
      get all their person element children
        get all their name attributes
          and return that node set

> I tried looking up the documentation for the saxon:evaluate and
> xalan:evaluate() but I couldnt answer the question.

If you want to learn about XPath expressions, you should have a look
at the XPath Recommendation at http://www.w3.org/TR/xpath.  Or one of
the online tutorials about them.

> Do I need an extra slash between $container and the $path?

It depends what you want. If the nodes in the $container variable are
the parents of the account elements, then no, you shouldn't have the
extra slash. If the nodes in the $container variable are just
ancestors of the account elements, then yes, you do.

I hope that helps,

Jeni

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



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread