【发布时间】:2014-03-28 13:42:19
【问题描述】:
我一直在尝试将 xslt 文件编译成 java 类并不断收到此错误。不知道我在这里做错了什么:
java com.sun.org.apache.xalan.internal.xsltc.cmdline.Compile test.xslt
java.lang.NullPointerException
at com.sun.org.apache.xalan.internal.xsltc.compiler.Parser.parse(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC.compile(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC.compile(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC.compile(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.cmdline.Compile.main(Unknown Source)
Compiler errors:
Could not compile stylesheet
我的 test.xslt 文件:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/hello-world">
<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
<H1>
<xsl:value-of select="greeting"/>
</H1>
<xsl:apply-templates select="greeter"/>
</BODY>
</HTML> </xsl:template> <xsl:template match="greeter">
<DIV>from <I><xsl:value-of select="."/></I></DIV>
</xsl:template>
</xsl:stylesheet>
【问题讨论】:
-
大于号 (
>) 是 .xslt 文件的一部分吗? -
您的意思是结束标记符号 (>)?是的,它是其中的一部分。
-
文件中最初没有,每一行都以结束标记符号开头。其他问题:你用什么命令编译文件?
-
java com.sun.org.apache.xalan.internal.xsltc.cmdline.Compile test.xslt
-
能够编译...将 test.xslt 更改为 test.xsl 并尝试