Question

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!

Was it helpful?

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().

OTHER TIPS

See S9APIExamples.java :

String[] fruit = {"apple", "banana", "cherry"};
QName paramName = new QName("in");
for (String s: fruit) {
    StringWriter sw = new StringWriter();
    out.setOutputWriter(sw);
    t.setParameter(paramName, new XdmAtomicValue(s));
    t.setDestination(out);
    t.transform();
    System.out.println(s + ": " + sw.toString());
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top