我有一个在Firefox中运行良好的XPath表达式,但是当我在IE中查看该文件时出现错误。是否有办法让IE了解我的表达?
我的XSL(我删除了很多,所以它更容易看到)。
<?xml version="1.0"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:date="http://exslt.org/dates-and-times" exclude-result-prefixes="#all" >
<xsl:output indent="yes"/>
<xsl:output method="html" encoding="UTF-8"/>
<xsl:template match="/">
<html>
<head>
<title>
<xsl:value-of select="versions/project" />
</title>
<style type="text/css">
...
</style>
</head>
<body>
<div class="content">
<xsl:for-each select="/releasenotes/notes/note[component/@type=$unitTag]">
<xsl:for-each select=".[component/@number=$versionNumber and text/@type='new']">
<li type="disc">
<xsl:value-of select="text" />
<xsl:for-each select="component[not(@type=$unitTag)]">
<xsl:sort select="@type" order="ascending"/>
, <a href="#{@type}_{@number}">
<xsl:variable name="unitType" select="@type"/>
<xsl:value-of select="//components/component[tag=$unitType]/name" /> (<xsl:value-of select="@number" />)
</a>
</xsl:for-each>
</li>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
问题似乎在于这一行:
<xsl:for-each select=".[component/@number=$versionNumber and text/@type='new']">
导致此错误:
Expected token 'EOF' found '['. .-->[<--component/@number='$versionNumber' and text/@type='new']
答案 0 :(得分:1)
对于变通方法,尝试使用等效的,未缩写的表达式.
替换该特定self::node()
,以使XSL跨浏览器工作。有关XPath中缩写步骤(.
和..
)之后谓词的相关最新问题:Selenium WebDriver Xpath current element attribute reports invalid Xpath exception
答案 1 :(得分:1)
而不是
<xsl:for-each select="/releasenotes/notes/note[component/@type=$unitTag][component/@number=$versionNumber and text/@type='new']">
似乎你只是想要
<xsl:for-each select="/releasenotes/notes/note[component/@type=$unitTag and component/@number=$versionNumber and text/@type='new']">
或
Vue.component('vimeo', {
template: '<iframe src="https://player.vimeo.com/video/' + this.videoId + '" width="640" height="360" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>',
props: ['videoId']
});
Vue.component('videos', {
template: '<div id="videos">' +
'<div v-for="videoId in videoIds">' +
'<vimeo :video-id="videoId"></vimeo>' +
'</div>' +
'</div>',
computed: {
videoIds: function() {
return store.state.videoIds;
}
}
});
答案 2 :(得分:1)
.[condition]
,所以IE拒绝它是正确的。
您实际上可以替换
<xsl:for-each select=".[condition]">
与
<xsl:if test="condition">
或按照Martin Honnen的建议将其合并到父xsl:for-each
中。