当我尝试运行我的程序时,我无法弄清楚为什么我一直收到错误"无法编译stlyesheet".我假设它在我的样式表中是一个错误,但我似乎无法找到它.
我可能只是看着它,但任何帮助将不胜感激.
谢谢!xsl可以在下面找到.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<PhoneBook>
<xsl:apply-templates/>
</PhoneBook>
</xsl:template>
<xsl:template match="AddressEntry">
<Entry>
<xsl:apply-templates select="Name"/>
<xsl:apply-templates select="Address"/>
</Entry>
</xsl:template>
<xsl:template match="Name">
<Name>
<xsl:apply-templates select="LastName"/>,
<xsl:apply-templates select="FirstName"/>
</Name>
</xsl:template>
<xsl:template match="Address">
<LocatorInfo>
<xsl:apply-templates select="PostalAddress/Street"/>
<xsl:apply-templates select="PostalAddress/City"/>
<xsl:apply-templates select="PostalAddress/PostalCode"/>
<xsl:apply-templates select="Phone"/>
</LocatorInfo>
</xsl:template>
<xsl:template match="FirstName">
<xsl:value-of select="."/>
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="LastName">
<xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)
Mat*_*een 11
您version在xsl:stylesheet标记中指定了两次.纠正这个允许它编译.
作为旁注,如果您没有可编译或验证XSL的程序,则可以使用以下命令始终通过Java运行它
java com.sun.org.apache.xalan.internal.xsltc.cmdline.Compile test.xsl
Run Code Online (Sandbox Code Playgroud)
它将尝试编译您的XSL并在那时显示任何语法错误.当您没有合适的工具时,对于这样的事情进行故障排除非常有用.
您已经被告知为什么您的样式表无效,但您需要解决更深层次的问题:为什么您没有看到错误消息?
我不知道您是否在使用 Saxon,但症状表明您可能正在使用。如果您尝试从 Java 或 .NET 应用程序中编译样式表,编译错误消息将默认写入 System.err 输出流。在许多情况下,例如在 Web 服务器甚至桌面 GUI 中运行的应用程序中,System.err 的内容可能不会出现在您的屏幕上,因此将输出定向到您可以找到的地方(使用web应用程序,至少在开发过程中,我经常将错误信息写入HTML响应页面)。API 中有多种机制可以实现这一点,例如通过编写您自己的 ErrorListener - 详细信息取决于您使用的 API。
或者,使用专为此目的而设计的开发环境(例如 oXygen 或 Stylus Studio)开发和调试您的样式表。
| 归档时间: |
|
| 查看次数: |
12233 次 |
| 最近记录: |