【问题标题】:Can't compile .xslt into java class file无法将 .xslt 编译成 java 类文件
【发布时间】: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>

【问题讨论】:

  • 大于号 (&gt;) 是 .xslt 文件的一部分吗?
  • 您的意思是结束标记符号 (>)?是的,它是其中的一部分。
  • 文件中最初没有,每一行都以结束标记符号开头。其他问题:你用什么命令编译文件?
  • java com.sun.org.apache.xalan.internal.xsltc.cmdline.Compile test.xslt
  • 能够编译...将 test.xslt 更改为 test.xsl 并尝试

标签: java xml xslt


【解决方案1】:

试试 Apache 的 Xalan 版本。它通常比 JDK 附带的版本更可靠。

【讨论】:

  • 它不是我的……它是我的竞争对手之一!但如果答案有效,请接受。并不是说我关心布朗尼点(我太老了),但是绿色的勾号对线程的后续读者有帮助。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2023-03-12
  • 1970-01-01
  • 1970-01-01
  • 2020-12-10
  • 2020-06-26
  • 2022-10-11
  • 1970-01-01
相关资源
最近更新 更多