使用 XSL 进行解析

发布于 2025-01-02 16:47:31 字数 2610 浏览 3 评论 0原文

Firefox 出现以下错误: 加载样式表时出错:解析 XSLT 样式表失败。

在 Google Chrome 中,它显示一个空白页面。

这是我的 .xsl 的代码

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">

<html>
    <head>
        <title>Curriculum Vitae</title>

        <link rel="stylesheet" type="text/css" href="css/myStyle.css"/>

        <script type="text/javascript" src="js/jquery-1.6.4.min.js"></script>
        <script type="text/javascript" src="js/script.js"></script>
    </head>

<body>
    <h1>Curriculum Vitae: Matthew Stanley Klein</h1>
    <br/>

    <ul id="nav">
        <li><a href="#">General Information</a></li>
        <li><a href="#">Work Experience</a></li>
        <li><a href="#">Miscellaneous</a></li>
        <li><a href="#">References</a></li>
        <li><a href="#">Showreel</a></li>
    </ul>

    <xsl:for-each select="references/company">
        <xsl:choose>
            <xsl:when test="name != ''">
                <dl>
                    <dt><xsl:value-of select="name" /></dt>
                    <dd>
                        <dl>
                            <dt>Name of Person: <xsl:value-of select="person" /></dt>
                            <dd>
                                <xsl:when test="cellphone != ''">
                                    Cellphone:  <xsl:value-of select="cellphone" />
                                </xsl:when>

                                <xsl:when test="work != ''">
                                    <br/>
                                    work: <xsl:value-of select="work" />
                                </xsl:when>

                                <xsl:when test="email != ''">
                                    <br/>
                                    email: <xsl:value-of select="email" />
                                </xsl:when>
                            </dd>
                        </dl>
                    </dd>
                </dl>
            </xsl:when>
            <hr/>
        </xsl:choose>
    </xsl:for-each>
</body>
</html>

</xsl:template>

</xsl:stylesheet>

是什么导致了此错误?

Firefox gives the following error:
Error loading stylesheet: Parsing an XSLT stylesheet failed.

In Google Chrome it shows a blank page.

Here is the code for my .xsl

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">

<html>
    <head>
        <title>Curriculum Vitae</title>

        <link rel="stylesheet" type="text/css" href="css/myStyle.css"/>

        <script type="text/javascript" src="js/jquery-1.6.4.min.js"></script>
        <script type="text/javascript" src="js/script.js"></script>
    </head>

<body>
    <h1>Curriculum Vitae: Matthew Stanley Klein</h1>
    <br/>

    <ul id="nav">
        <li><a href="#">General Information</a></li>
        <li><a href="#">Work Experience</a></li>
        <li><a href="#">Miscellaneous</a></li>
        <li><a href="#">References</a></li>
        <li><a href="#">Showreel</a></li>
    </ul>

    <xsl:for-each select="references/company">
        <xsl:choose>
            <xsl:when test="name != ''">
                <dl>
                    <dt><xsl:value-of select="name" /></dt>
                    <dd>
                        <dl>
                            <dt>Name of Person: <xsl:value-of select="person" /></dt>
                            <dd>
                                <xsl:when test="cellphone != ''">
                                    Cellphone:  <xsl:value-of select="cellphone" />
                                </xsl:when>

                                <xsl:when test="work != ''">
                                    <br/>
                                    work: <xsl:value-of select="work" />
                                </xsl:when>

                                <xsl:when test="email != ''">
                                    <br/>
                                    email: <xsl:value-of select="email" />
                                </xsl:when>
                            </dd>
                        </dl>
                    </dd>
                </dl>
            </xsl:when>
            <hr/>
        </xsl:choose>
    </xsl:for-each>
</body>
</html>

</xsl:template>

</xsl:stylesheet>

What is causing this error?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

浅唱ヾ落雨殇 2025-01-09 16:47:31
  1. xsl:when 父级应该是 xsl:choose
  2. xsl:choose 应仅包含 xsl:when(而不是

  1. xsl:when parent should be xsl:choose.
  2. xsl:choose should contain only xsl:when (not <hr/>)
清旖 2025-01-09 16:47:31

xsl:when 必须是 xsl:choose 的子级,而不是

,并且 xsl:choose 可以仅将 xsl:whenxsl:otherwise 作为子项,而不是 <\hr>

您可以使用 VisualStudio Express 和 Eclipse XML 包作为 XSLT 编辑器来在编写这些内容时查找这些内容。

xsl:when must be child of xsl:choose, not <dd>, and xsl:choose can only have xsl:when and xsl:otherwise as children, not <\hr>.

You can use VisualStudio Express and Eclipse XML package as XSLT editors to find these things while you write them.

北陌 2025-01-09 16:47:31

也许是 之间的


它应该位于 内,或位于 之外...

Maybe it's the <hr/> between </xsl:when> and </xsl:choose>?

It should be either within <xsl:when>, or outside <xsl:choose>...

凌乱心跳 2025-01-09 16:47:31

编写 XSLT 时使用 XML Spy 或类似工具 - 该工具会快速告诉您什么是允许的,什么是不允许的。

Use XML Spy or similar tools when writing XSLT - the tool will quickly tell you what is and what is not allowed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文