xsltsaxonxsl-stylesheet

How can I pass a parameter to my xslt stylesheet with Saxon under Java?


I am using Saxon 9 HE and in NetBeans 7.0.1, I get the following error when I try to send a parameter to my stylesheet:

enter image description here

Just to make sure, is that the good way to send a parameter so I can get it back with

<xsl:param ... /> ?

If so, how can I use it?

Thank you!


Solution

  • From the message it seems quite obvious that you need to pass an net.sf.saxon.s9api.Qname as the first argument (not just the string "myVar").

    And the second argument must be constructed as an net.sf.saxon.s9api.XdmValue.

    Just to make sure, is that the good way to send a parameter so I can get it back with

    <xsl:param ... /> ?

    In your XSLT stylesheets (the primary one and any stylesheet module that is referenced in an xsl:import or an xsl:include directive) you must have a global (child of xsl:stylesheet) xsl:param with the same name as the string used to construct the Qname that you are passing as the first argument to setParameter().

    When the setParameter() method is executed and then the transformation is invoked, the corresponding global xsl:param will have the value that was used to construct the XdmValue passed as the second argument to setParameter().