【发布时间】:2018-03-20 16:03:48
【问题描述】:
我正在尝试在我的 XSLT 中将输入字符串解码为 base64。
我已经定义了 2 个命名空间:
xmlns:base64Decoder="java:java.util.Base64.Decoder"
xmlns:base64="java:java.util.Base64"
这是我的简单尝试:
<xsl:variable name="base64Value" select="'aGVsbG8='"/>
<xsl:variable name="deco" select="base64:getDecoder()"/>
<xsl:value-of select="base64Decoder:decode($deco, $base64Value)"/>
执行没有编译并向我显示消息:
找不到名为 {java:java.util.Base64.Decoder}decode() 的匹配 2 参数函数
我知道还有其他方法,但我特别想知道为什么这个方法不起作用。
提前致谢。
添加氧气诊断信息以解决方法调用(请参阅跟踪:“类 java.util.Base64.Decoder 无法加载:java.util.Base64.Decoder”几乎在最后):
Looking for function {java:java.util.Base64}getDecoder
Trying net.sf.saxon.functions.SystemFunctionLibrary
Trying net.sf.saxon.style.StylesheetFunctionLibrary
Trying com.saxonica.functions.extfn.ExtraFunctionLibrary
Trying net.sf.saxon.functions.ConstructorFunctionLibrary
Trying net.sf.saxon.query.XQueryFunctionLibrary
Trying net.sf.saxon.functions.IntegratedFunctionLibrary
Trying com.saxonica.config.JavaExtensionLibrary
Looking for method getDecoder in namespace java:java.util.Base64
Number of actual arguments = 0
Loading java.util.Base64
Looking in Java class class java.util.Base64
Trying method getMimeDecoder: name does not match
Trying method getDecoder: name matches
Method is static
Method has 0 arguments; expecting 0
Found a candidate method:
public static java.util.Base64$Decoder java.util.Base64.getDecoder()
Trying method getEncoder: name does not match
Trying method getMimeEncoder: name does not match
Trying method getMimeEncoder: name does not match
Trying method getUrlDecoder: name does not match
Trying method getUrlEncoder: name does not match
Trying method wait: name does not match
Trying method wait: name does not match
Trying method wait: name does not match
Trying method equals: name does not match
Trying method toString: name does not match
Trying method hashCode: name does not match
Trying method getClass: name does not match
Trying method notify: name does not match
Trying method notifyAll: name does not match
Looking for function {java:java.util.Base64.Decoder}decode
Trying net.sf.saxon.functions.SystemFunctionLibrary
Trying net.sf.saxon.style.StylesheetFunctionLibrary
Trying com.saxonica.functions.extfn.ExtraFunctionLibrary
Trying net.sf.saxon.functions.ConstructorFunctionLibrary
Trying net.sf.saxon.query.XQueryFunctionLibrary
Trying net.sf.saxon.functions.IntegratedFunctionLibrary
Trying com.saxonica.config.JavaExtensionLibrary
Looking for method decode in namespace java:java.util.Base64.Decoder
Number of actual arguments = 2
Loading java.util.Base64.Decoder
The class java.util.Base64.Decoder could not be loaded: java.util.Base64.Decoder
Trying net.sf.saxon.style.StylesheetFunctionLibrary
Function {java:java.util.Base64.Decoder}decode not found!
Loading java.util.Base64.Decoder
The class java.util.Base64.Decoder could not be loaded: java.util.Base64.Decoder
【问题讨论】:
-
那么您到底使用哪个版本的 XSLT 处理器?对 Java 的调用不是标准化的,如何调用也不取决于特定的 XSLT 处理器。
-
感谢您的关注:我在 XSLT 2.0 中使用 Saxon PE 9.4 并在 Java 8 下运行。