2

と を使用Saxon 9 HENetBeans 7.0.1ています。スタイルシートにパラメーターを送信しようとすると、次のエラーが発生します。

ここに画像の説明を入力

念のために言っておきますが、パラメーターを送信して元に戻すことができるのは良い方法です

<xsl:param ... />?

もしそうなら、どうすればそれを使うことができますか?

ありがとうございました!

4

2 に答える 2

3

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());
}
于 2012-01-22T04:49:04.750 に答える
1

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

于 2012-01-22T04:54:14.387 に答える