从 XSL 调用 Java API 抛出异常“URI http://xml.apache.org/xslt/java 未识别外部 Java 类" [英] Calling Java API from XSL throws exception "The URI http://xml.apache.org/xslt/java does not identify an external Java class"

查看:44
本文介绍了从 XSL 调用 Java API 抛出异常“URI http://xml.apache.org/xslt/java 未识别外部 Java 类"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 xsl 文件使用 SAXON 处理器,如下所示:

I'm using SAXON processor for xsl file as follows:

   <?xml version="1.0" encoding="utf-8"?>
   <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                    version="1.0" xmlns:java="http://xml.apache.org/xslt/java"
                    exclude-result-prefixes="java">
    <xsl:output method="xml"/>
    <xsl:template name="printjavaDate">
    <xsl:variable name="date" select="java:java.util.Date.new()"/>
    <xsl:value-of select=""/>
    </xsl:template>

但是这段代码对我不起作用.

But this code isn't working for me.

它抛出错误:

javax.xml.transform.TransformerException: The URI http://xml.apache.org/xslt/java does not identify an external Java class
                at com.icl.saxon.style.StyleElement.styleError(StyleElement.java:803)

我不确定为什么会发生这种情况.我要求只使用 XSLT 1.0.

I'm not sure why is this happening. I've requirement of using XSLT 1.0 only.

我能知道是什么导致了这个错误吗?希望这里的专家能帮助我.

Can I know what is causing this error? Hope experts here will help me out.

推荐答案

我猜 xmlns:java="http://xml.apache.org/xslt/java" 是 Xalan 特定的,如果您想在 Saxon 6 中使用扩展函数,然后查看 http://saxon.sourceforge.net/saxon6.5.5/extensibility.html.

I guess xmlns:java="http://xml.apache.org/xslt/java" is Xalan specific, if you want to use extension functions in Saxon 6 then see http://saxon.sourceforge.net/saxon6.5.5/extensibility.html.

这是一个适用于 Saxon 6.5 的示例:

Here is an example that works for me with Saxon 6.5:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
    xmlns:date="java:java.util.Date">

    <xsl:output method="xml"/>

    <xsl:template name="printjavaDate" match="/">
        <xsl:variable name="date" select="date:new()"/>
        <xsl:value-of select="$date"/>
    </xsl:template>

</xsl:stylesheet>

这篇关于从 XSL 调用 Java API 抛出异常“URI http://xml.apache.org/xslt/java 未识别外部 Java 类"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆