The value of $parameter is not an XPath expression; it is the result of evaluating an XPath expression. It's evaluated at the point where it is passed to Saxon, not at the point where the parameter is referenced.

The main use of XPath expressions as parameters is for simple constant expressions such as 

current-date()

or

xs:date('2000-01-01')

If you want a parameter whose value is a string containing an XPath expression, supply it (and declare it) as a string, and evaluate it using saxon:evaluate() or xsl:evaluate.

Michael Kay
Saxonica




On 8 Apr 2014, at 16:20, Christian Schwaderer <c_schwaderer@hotmail.com> wrote:

Hi there,

I'm new to this list and maybe asking a beginner's question.

I use Saxon EE 9.5.1.3 using oXygen XML Editor.
I try to use a parameter from the "Transformation scenario windows" (which is, I hope, equal to the Saxon command line options).
But it doesn't work.

This is my input:

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <element>1</element>
    <element>2</element>
</root>

This is my xslt:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    exclude-result-prefixes="xs"
    version="2.0">
    
    <xsl:param name="parameter"/>
    
    <xsl:template match="/">
        
        <output_root>
            
            <xsl:for-each select="$parameter">
                <output_element>
                    <xsl:value-of select="."/>
                </output_element>
            </xsl:for-each>
            
        </output_root>
        
    </xsl:template>
    
</xsl:stylesheet>

In the oXygen parameter window I set the following:
name        value            
parameter    //element     [x] evaluate as XPath

Expected output is:
<output_root>
 <output_element>1</output_element>
 <output_element>2</output_element>
</output_root>

I hoped Saxon would create from the input parameter //element an Xpath expression selecting all <element> elements. But that isn't the case. Instead I get the error message: "Cannot evaluate the XPath expression '//element' for parameter 'parameter'. Reason: Finding root of tree: the context item is absent"

I don't understand this: There is context node! It is the root element "/".

Is this an issue of oXygen or is it me misunderstanding the concept of parameters?

Thanks in advance!
------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration
Continuously Automate Build, Test & Deployment 
Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help