Subject: Re: [xsl] question on paths From: Monosij Dutta-Roy <monosij.forums@xxxxxxxxx> Date: Thu, 27 May 2010 00:35:32 -0400 |
I think I understand what you mean. I will have to try it out tomorrow. For me the Document is the root node, so I will try to follow David's suggestions. Again, I really appreciate your help and fast responses and will keep you updated. I will also try to send the error messages generated by Saxon. Thanks. monosij On Wed, May 26, 2010 at 7:13 PM, Michael Kay <mike@xxxxxxxxxxxx> wrote: > > I'm sorry that you are having trouble understand the responses you were > given. I'm afraid I may just be repeating the same response in slightly > different words. > >> >> I am writing this function: >> --------------- >> <xsl:function name="fnc:getPatientRolePath"> >> B B B <xsl:param name="Version"/> >> B B B <xsl:choose> >> B B B B B B <xsl:when test="$Version = '3.0'"> >> B B B B B B B B B <xsl: >> select="/n1:Document/n1:recordTarget/n1:patientRole"/> >> B B B B B B </xsl:when> >> B B B B B B <xsl:otherwise>UNDEFINED</xsl:otherwise> >> B B B </xsl:choose> >> </xsl:function> > > As I explained in my previous response, "xsl:" is not a valid XML element > name, so this won't even get past the XML parser. >> --------------- >> I am writing this function so as to create a variable >> patientRolePath to hold the value: >> /n1:Document/n1:recordTarget/n1:patientRole. > > As David Carlisle explained in his response, you can't hold fragments of > XPath expressions in variables, you can only hold values. However, that's > fine: to do what you describe below, you don't need to hold the path in the > variable, you can hold the set of nodes selected by the path. > >> This is because then I can use the variable name >> patientRolePath and append child nodes and get required >> values such as: >> >> $patientRolePath/id >> $patientRolePath/lastName >> $patientRolePath/firstName >> >> However this that function I can't seem to write it to return >> with the path. >> <xsl: select="/n1:Document/n1:recordTarget/n1:patientRole"/> >> is not valid > > Correct, "xsl:" is not a valid element name. > > As I explained before, it's useful to tell us what error messages you are > getting, rather than simply saying something doesn't work. Then we can > explain the error to you. > > B HOWEVER <xsl:variable name="patientRole" >> select="/n1:Document/n1:recordTarget/n1:patientRole"/> >> written as a statement is valid. But does not return me anything. > > A variable declaration on its own doesn't return anything. A reference to > the variable would return something, but a variable that is never referenced > is useless. > > Regards, > > Michael Kay > http://www.saxonica.com/ > http://twitter.com/michaelhkay
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] question on paths, Michael Kay | Thread | Re: [xsl] question on paths, Monosij Dutta-Roy |
RE: [xsl] question on paths, Michael Kay | Date | [xsl] Transform some attributes int, Philipp Kursawe |
Month |