Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml XSL:Xpath查询在<;xsl:apply templates>;Isn';我不返回任何结果_Xml_Xslt_Xpath - Fatal编程技术网

Xml XSL:Xpath查询在<;xsl:apply templates>;Isn';我不返回任何结果

Xml XSL:Xpath查询在<;xsl:apply templates>;Isn';我不返回任何结果,xml,xslt,xpath,Xml,Xslt,Xpath,注1:这是我的第一个问题。请温柔点。 注2:是的,这是家庭作业。我不想寻求帮助,但我遇到了麻烦。如果你不想告诉我答案,建议在哪里寻找答案同样会很感激。多谢各位 我试图编写一个XSLT表,查看目标XML文件中每个DVD元素的类型属性。它应该返回一个列表,其中每个不同的值只列出一次,并计算每个值被找到的次数 我认为我的XPath是错误的。为了调试,我尝试了使用语句来尝试不同的XPath查询,但没有任何运气 这是XSL文件(我已经尝试将其剥离到最底层) 浏览:按类型分类的DVD 按流派浏览 () -

注1:这是我的第一个问题。请温柔点。
注2:是的,这是家庭作业。我不想寻求帮助,但我遇到了麻烦。如果你不想告诉我答案,建议在哪里寻找答案同样会很感激。多谢各位

我试图编写一个XSLT表,查看目标XML文件中每个DVD元素的类型属性。它应该返回一个列表,其中每个不同的值只列出一次,并计算每个值被找到的次数

我认为我的XPath是错误的。为了调试,我尝试了使用
语句来尝试不同的XPath查询,但没有任何运气

这是XSL文件(我已经尝试将其剥离到最底层)


浏览:按类型分类的DVD
按流派浏览
() - 
以下是XML文件的相关部分:

<?xml version="1.0" encoding="UTF-8"?>
<!-- dvdlistExample.xml -->
<?xml-stylesheet type="text/xsl" href="BrowseAllExample.xsl"?>
<dvdlist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://example.com/dvdlist ./schema/dvdlist.xsd"
    xmlns="http://example.com/dvdlist">
    <DVD genre="Comedy" itemnum="ID-20">
        <title>American Wedding</title>
        <year>2003</year>
        <price>18.89</price>
        <talent>
            <director>Jesse Dylan</director>
            <actor>Jason Biggs</actor>
            <actor>Sean William Scott</actor>
            <actor/>
        </talent>
        <ratings mpaa="NR" customer="3"/>
        <pics id="ID-20">
            <thumbnail>Wedding-small.jpg</thumbnail>
            <large>Wedding-big.jpg</large>
        </pics>
    </DVD>
    <DVD genre="Action" itemnum="ID-2">
        <title>Badboys II</title>
        <year>2003</year>
        <price>20.27</price>
        <talent>
            <director>Michael Bay</director>
            <actor>Will Smith</actor>
            <actor>Martin Lawrence</actor>
        </talent>
        <ratings mpaa="R" customer="3"/>
        <pics id="ID-2">
            <thumbnail>Badboys-small.jpg</thumbnail>
            <large>Badboys-big.jpg</large>
        </pics>
    </DVD>
    <!--Other DVD entries removed to save space-->
</dvdlist>

美式婚礼
2003
18.89
杰西·迪伦
杰森·比格斯
肖恩·威廉·斯科特
widding-small.jpg
婚礼-大.jpg
坏蛋II
2003
20.27
迈克尔湾
威尔·史密斯
马丁·劳伦斯
Badboys-small.jpg
Badboys-big.jpg
应该可以帮助您满足您的需求


XML名称空间只是实现XML元素和属性唯一性的一种方式。如果两个用户/公司/任何人定义了一个
元素,那么名称空间就是它们分开的方式。例如,您可以选择两个不同的
元素以及相应的名称空间来处理它们。

提示:您的XML绑定到一个名称空间:
xmlns=”http://example.com/dvdlist“
。如果要在XSLT/XPath中处理这些元素,则需要在XPath中声明名称空间并使用前缀,或者在谓词过滤器中匹配
namespace-uri()。我不记得我的作业有那么有趣+1对于写得很好的问题。+1希望每个问题都能考虑得这么好!对这是一个常见问题。这可能是重复的,加上马兹·汉森在上面的评论,引导我朝着正确的方向前进。我没有意识到我有一个名称空间问题。我从来没有想到XSLT中的XPath由于名称空间的原因无法解析目标XML中的元素,尽管现在看起来很明显。谢谢大家!
<?xml version="1.0" encoding="UTF-8"?>
<!-- dvdlistExample.xml -->
<?xml-stylesheet type="text/xsl" href="BrowseAllExample.xsl"?>
<dvdlist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://example.com/dvdlist ./schema/dvdlist.xsd"
    xmlns="http://example.com/dvdlist">
    <DVD genre="Comedy" itemnum="ID-20">
        <title>American Wedding</title>
        <year>2003</year>
        <price>18.89</price>
        <talent>
            <director>Jesse Dylan</director>
            <actor>Jason Biggs</actor>
            <actor>Sean William Scott</actor>
            <actor/>
        </talent>
        <ratings mpaa="NR" customer="3"/>
        <pics id="ID-20">
            <thumbnail>Wedding-small.jpg</thumbnail>
            <large>Wedding-big.jpg</large>
        </pics>
    </DVD>
    <DVD genre="Action" itemnum="ID-2">
        <title>Badboys II</title>
        <year>2003</year>
        <price>20.27</price>
        <talent>
            <director>Michael Bay</director>
            <actor>Will Smith</actor>
            <actor>Martin Lawrence</actor>
        </talent>
        <ratings mpaa="R" customer="3"/>
        <pics id="ID-2">
            <thumbnail>Badboys-small.jpg</thumbnail>
            <large>Badboys-big.jpg</large>
        </pics>
    </DVD>
    <!--Other DVD entries removed to save space-->
</dvdlist>