xsl-list
[Top] [All Lists]

Re: [xsl] question on paths

2010-05-26 17:23:01
On 26/05/2010 23:11, Monosij Dutta-Roy wrote:
Hello to all -

I am new to XSLT but not to data / programming. So I hope the
following makes sense:
Using XSLT 2.0, SaxonHE 9.2, JDK 1.6
I am trying to write a function that will test certain paths are valid
and keep them as variables before I use those paths to get child
nodes.

like most programming languages (lisp being an honourable exception) xslt doesn't have a datatype corresponding to fragments of syntax such as a path. variables hold values.

the proposed xslt 2.1 has a evaluate function (available as saxon:evaluate in saxon 9.1 or commercial versions of 9.2) which would evaluate a path passed as a string, but it isn't clear if that is what you need here.

------------------------------

So I am using the function below and get an error on the line:
             <xsl: select="/n1:recordDocument/n1:recordTarget/n1:patientRole"/>

At the top level of a function body ther eis no current item and in particular no current document so any path starting with / will raise an error.

You need to give your function a parameter, say $x and then use something like
root($x)/n1:recordDocument/n1:recordTarget/n1:patientRole
so if you pass in any node from the document it will evaluate that path from the root of the document.


David

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>