Xml <;xsl:sort-cause加载样式表时出错:解析XSLT样式表失败

Xml <;xsl:sort-cause加载样式表时出错:解析XSLT样式表失败,xml,xslt,Xml,Xslt,我试图弄清楚如何使用XSL按价格对目录的XML列表进行排序。现在,它只显示来自XML的正确信息。如果我使用以下代码 <xsl:template match="catalog"> <html> <head> <title>book catalog</title> </head> <body> <h1>

我试图弄清楚如何使用XSL按价格对目录的XML列表进行排序。现在,它只显示来自XML的正确信息。如果我使用以下代码

<xsl:template match="catalog">
    <html>
        <head>
            <title>book catalog</title>
        </head>
        <body>
            <h1>book catalogs</h1>
            <table border="1">
                <thead>
                    <tr bgcolor="red">
                        <td>id</td><td>author</td><td>title</td><td>generation</td><td>price</td><td>publish date</td><td>description</td>
                    </tr>
                </thead>
                <xsl:for-each select="book">
                    <xsl:sort data-type="number" select="price" />
                    <tbody>
                    <tr>

                        <td><xsl:value-of select="@id"/></td>
                        <td><xsl:value-of select="author"/></td>
                        <td><xsl:value-of select="title"/></td>
                        <td><xsl:value-of select="generation"/></td>
                        <td><xsl:value-of select="price"/></td>
                        <td><xsl:value-of select="publishDate"/></td>
                        <td><xsl:value-of select="description"/></td>
                    </tr>
                </tbody>
                </xsl:for-each>
            </table>
        </body>
    </html>



</xsl:template>

书的目录
图书目录
IDauthortitleGeneration价格发布日期描述

但如果我更改xsl:sort的位置并将其放在tbody标记之后,它将生成错误。 这两种代码之间有什么区别?是否有必要在xsl:for后面插入xsl:sort,以解决问题

        <body>
            <h1>book catalogs</h1>
            <table border="1">
                <thead>
                    <tr bgcolor="red">
                        <td>id</td><td>author</td><td>title</td><td>generation</td><td>price</td><td>publish date</td><td>description</td>
                    </tr>
                </thead>
                <xsl:for-each select="book">
                    <tbody>

                        <tr>
                        <xsl:sort data-type="number" select="price" />

                        <td><xsl:value-of select="@id"/></td>
                        <td><xsl:value-of select="author"/></td>
                        <td><xsl:value-of select="title"/></td>
                        <td><xsl:value-of select="generation"/></td>
                        <td><xsl:value-of select="price"/></td>
                        <td><xsl:value-of select="publishDate"/></td>
                        <td><xsl:value-of select="description"/></td>
                    </tr>
                </tbody>
                </xsl:for-each>
            </table>
        </body>

图书目录
IDauthortitleGeneration价格发布日期描述

符合规范要求

:


:



根据规范,
xsl:sort
定义(如果存在)必须是每个
中的第一个子元素

:


:



xsl:sort
定义(如果存在)必须是
for each

xsl:sort必须作为xsl:for each的第一个子元素。你希望把它放在别处能得到什么?谢谢你的帮助。没什么特别的,只是我想知道区别是什么,确切的问题是什么。非常感谢,您的评论帮助了我。xsl:sort必须作为xsl:for each的第一个子项。你希望把它放在别处能得到什么?谢谢你的帮助。没什么特别的,只是我想知道区别是什么,确切的问题是什么。谢谢你,你的评论帮助了我。
<!-- Category: instruction -->
<xsl:for-each
  select = node-set-expression>
  <!-- Content: (xsl:sort*, template) -->
</xsl:for-each>
<!-- Category: instruction -->
<xsl:for-each
  select = expression>
  <!-- Content: (xsl:sort*, sequence-constructor) -->
</xsl:for-each>