xsl-list
[Top] [All Lists]

RE: [xsl] question on paths

2010-05-26 18:14:11

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">
    <xsl:param name="Version"/>
    <xsl:choose>
        <xsl:when test="$Version = '3.0'">
            <xsl: 
select="/n1:Document/n1:recordTarget/n1:patientRole"/>
        </xsl:when>
        <xsl:otherwise>UNDEFINED</xsl:otherwise>
    </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.

 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 


--~------------------------------------------------------------------
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>