我寫了兩個文件錯誤的XSLT與Eclipse開普勒
第一個文件是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轉換」 出現的錯誤:
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文件並點擊'RUN'按鈕?我必須點擊XSL文件,然後選擇'XSL Transformation'吧? – CSnerd
您可以選擇XSL + XML文件,也可以爲XML文件設置運行配置(請參閱更新後的答案)。 –