Html XSL选择不正确提取数据的情况

Html XSL选择不正确提取数据的情况,html,xml,xslt,xsl-choose,Html,Xml,Xslt,Xsl Choose,我正在尝试使用XSLChoose来填充一个选择框。盒子里会有更多的选项,一旦我有了这个工作,我只需要先让它工作。它正在正确加载,只是没有拉取e:name,因此选项框正在渲染,但为空,没有任何选项 这是我的XSL <xsl:template match="/"> <html> <body> <select id="epselect"> <xsl:element name="option"> <xsl:choose> &l

我正在尝试使用XSLChoose来填充一个选择框。盒子里会有更多的选项,一旦我有了这个工作,我只需要先让它工作。它正在正确加载,只是没有拉取e:name,因此选项框正在渲染,但为空,没有任何选项

这是我的XSL

<xsl:template match="/">

<html>
<body>


<select id="epselect">
<xsl:element name="option">
<xsl:choose>
<xsl:when test="dalehoward/e:ep/@id = 1">
<xsl:value-of select="e:name"/>
<xsl:attribute name="value">1</xsl:attribute>
</xsl:when>
<xsl:otherwise>
EP not found
</xsl:otherwise>
</xsl:choose>
</xsl:element>

</select>

</body>
</html>
</xsl:template>

1.
找不到EP
这是我的XML

<dalehoward         xmlns:artist="http://www.beatport.com/artist/dale-howard/78784"
                xmlns:e="http://www.beatport.com/artist/dale-howard/78784/releases"
                xmlns:t="http://www.beatport.com/artist/dale-howard/78784/tracks">



<artist:bio>
<artist:profilepic>profilepic.jpg</artist:profilepic>
<artist:dob>16/10/1987</artist:dob>
<artist:pob>Liverpool</artist:pob>
<artist:about>
English Deep House producer, Dale Howard, first burst onto the scene in 2009 with his debut EP on Neurotraxx Deluxe 'Gotta Be Deep', which topped the Beatport Deep House chart reaching the Number 1 spot. Since then he has been making waves with an array of releases on world renowned labels like Fear Of Flying, Loco Records, Off Recordings and many others. Aswell as having countless top 20's and 50's Dale has also reached Number 2 and Number 3 on the Beatport Deep House Chart with his tracks 'Dropout' and '4 Hour Bang', which also stayed in the Top 10 for 9 weeks. 2012 brought more success and high acclaim for Dale, with his productions gaining huge support from artists like DJ Sneak, Luciano, Reboot, Dyed Soundorom, Steve Lawler, Dubfire, Magda, M.A.N.D.Y, Homework, Huxley, Jordan Peak, Dusky, Robert Owens, Michelle Owen and loads more, as well as even more releases scheduled with world renowned record labels.
</artist:about>
</artist:bio>

<e:ep id="1">
    <e:name>Letters EP</e:name>
    <e:year>2012</e:year>
    <e:label>Static Audio</e:label>
    <e:image>letters.jpg</e:image>

        <t:track number="1" beatportrank="0">
            <t:name>Letters</t:name>
            <t:length>6.35</t:length>
            <t:ytubelink>2H2XDQqvbpc</t:ytubelink>
        </t:track>
        <t:track number="2" beatportrank="0">
            <t:name>Later</t:name>
            <t:length>7.56</t:length>
            <t:ytubelink>w61RrgBPahk</t:ytubelink>
        </t:track>
            <t:track number="3" beatportrank="0">
            <t:name>'89 Flava</t:name>
            <t:length>7:38</t:length>
            <t:ytubelink>Mgarl-FlVhQ</t:ytubelink>
        </t:track>
        <t:track number="4" beatportrank="0">
            <t:name>Safe Presentation</t:name>
            <t:length>7.55</t:length>
            <t:ytubelink>d_U38G9AwHk</t:ytubelink>
        </t:track>
</e:ep>
</dalehoward>

profilepic.jpg
16/10/1987
利物浦
英国深屋制作人戴尔·霍华德(Dale Howard)于2009年首次亮相,他在《Neurotaxx Deluxe》中的首张EP《一定要深》,在Beatport深屋排行榜上高居榜首,位居榜首。从那时起,他就在世界著名唱片公司的一系列发行中掀起了波澜,如《飞行恐惧》、《Loco唱片》、《非录音》等。除了拥有数不清的前20名和前50名之外,戴尔还凭借其曲目《辍学》和《4小时爆炸》在Beatport Deep House排行榜上分别名列第2和第3,这两首歌也连续9周保持在前10名的位置。2012年,戴尔获得了更多的成功和高度赞誉,他的作品获得了DJ斯克尔、卢西亚诺、Reboot、Dyed Soundorom、Steve Lawler、Dubfire、Magda、M.A.N.D.Y、家庭作业、赫胥黎、乔丹峰、黄昏、罗伯特·欧文斯、米歇尔·欧文等艺术家的大力支持,以及更多与世界著名唱片公司合作发行的唱片。
字母EP
2012
静态音频
letters.jpg
信件
6.35
2H2xDqVbpc
后来
7.56
W61RRK
89弗拉瓦
7:38
Mgarl FlVhQ
安全演示
7.55
d_u38g9awk

xsl:when
中,上下文节点仍然是
/
,因此表达式
/e:name
的等价元素,它永远不会匹配任何内容

您需要从上下文节点
调整XPath相对值

此外,还需要将
xsl:value移动到属性生成的下方。否则,将出现一个错误,即无法在包含元素的子元素之后创建属性

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:artist="http://www.beatport.com/artist/dale-howard/78784"
    xmlns:e="http://www.beatport.com/artist/dale-howard/78784/releases"
    xmlns:t="http://www.beatport.com/artist/dale-howard/78784/tracks">
    <xsl:template match="/">      
        <html>
            <body>
                <select id="epselect">
                    <xsl:element name="option">
                        <xsl:choose>
                            <xsl:when test="dalehoward/e:ep/@id = 1">
                                <xsl:attribute name="value">1</xsl:attribute>
                                <xsl:value-of select="dalehoward/e:ep[@id=1]/e:name"/>
                            </xsl:when>
                            <xsl:otherwise>
                                EP not found
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:element> 
                </select> 
            </body>
        </html>
    </xsl:template>
</xsl:stylesheet>

1.
找不到EP

非常好用,非常感谢,但愿我不是XSL的新手!