【问题标题】:Error of XSLT with Eclipse KeplerEclipse Kepler 的 XSLT 错误
【发布时间】:2014-01-25 18:06:34
【问题描述】:

我写了两个文件

第一个文件是NewFile.xml(我写了<?xml-stylesheet type="text/xsl" href="NewStylesheet.xsl"?> 在这个文件中),第二个文件是NewStylesheet.xsl(虽然我不认为xsl文件有错误,但我还是把它贴出来了):

<?xml version="1.0" encoding="ISO-8859-1"?>  
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">   
<xsl:template match="/">
  <html>
  <body>
    <h2>My CD Collection</h2>
    <table border="1">
    <tr bgcolor="#9acd32">
      <th align="left">Title</th>
      <th align="left">Artist</th>
    </tr>
    <xsl:for-each select="catalog/cd">
    <tr>
      <td><xsl:value-of select="title"/></td>
      <td><xsl:value-of select="artist"/></td>
    </tr>
    </xsl:for-each>
    </table>
  </body>
  </html>
</xsl:template>   
</xsl:stylesheet>

但是,当我运行“XSL Transformation”时出现错误:

15:55:02,242 INFO  [main] Main  - javax.xml.transform.TransformerFactory=null
15:55:02,243 INFO  [main] Main  - java.endorsed.dirs=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/endorsed
15:55:02,245 INFO  [main] Main  - launchFile: /Users/xuxu/Documents/workspace/.metadata/.plugins/org.eclipse.wst.xsl.jaxp.launching/launch/launch.xml
15:55:02,299 ERROR [main] JAXPSAXProcessorInvoker  - Could not compile stylesheet
15:55:02,300 ERROR [main] JAXPSAXProcessorInvoker  - Could not compile stylesheet
javax.xml.transform.TransformerConfigurationException: Could not compile stylesheet
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:886)
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:669)
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformerHandler(TransformerFactoryImpl.java:961)
    at org.eclipse.wst.xsl.jaxp.debug.invoker.internal.JAXPSAXProcessorInvoker.addStylesheet(JAXPSAXProcessorInvoker.java:136)
    at org.eclipse.wst.xsl.jaxp.debug.invoker.internal.JAXPSAXProcessorInvoker.transform(JAXPSAXProcessorInvoker.java:210)
    at org.eclipse.wst.xsl.jaxp.debug.invoker.internal.JAXPSAXProcessorInvoker.transform(JAXPSAXProcessorInvoker.java:186)
    at org.eclipse.wst.xsl.jaxp.debug.invoker.internal.Main.main(Main.java:73)
Caused by: java.io.FileNotFoundException: /Applications/eclipse/Eclipse.app/Contents/MacOS/NewStylesheet.xsl (No such file or directory)
    at java.io.FileInputStream.open(Native Method)

为什么说Caused by: java.io.FileNotFoundException: /Applications/eclipse/Eclipse.app/Contents/MacOS/NewStylesheet.xsl (No such file or directory)?这里有什么帮助吗?

【问题讨论】:

    标签: xml eclipse xslt xslt-1.0


    【解决方案1】:

    转换在 Eclipse 安装目录中运行时的当前目录,而不是包含文件的目录,因此 href="NewStylesheet.xsl" 找错了位置。

    根据this Tutorial,您确实&lt;?xml-stylesheet 放入XML 文件中。只需右键单击 XSL 文件并选择XSL Transformation

    This documentation 表示您可以选择一个 XSL 文件一个 XML 文件。它还说您可以使用Run Configuration 来配置用于 XML 文件的 XSL。

    【讨论】:

    • 所以我无法选择XML文件并点击RUN按钮?我必须点击 XSL 文件并选择 XSL Transformation 对吗?
    • 您可以选择 XSL + XML 文件,也可以为 XML 文件设置运行配置(请参阅更新的答案)。
    猜你喜欢
    • 1970-01-01
    • 2021-06-21
    • 1970-01-01
    • 1970-01-01
    • 2013-12-21
    • 1970-01-01
    • 2014-06-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多