2017-05-17 6 views
0

Firefoxでうまく動作するXPath式がありますが、IEでファイルを表示しているときにエラーが発生しました。 IEに表現を理解させるための回避策はありますか?xslファイルのXPath式がIEで動作しない

私のXSL(私はたくさん削除しましたので少し見やすくなりました)。

<xsl:for-each select=".[component/@number=$versionNumber and text/@type='new']"> 

このエラーが発生:

<?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" > 
 
\t <xsl:output indent="yes"/> 
 
\t <xsl:output method="html" encoding="UTF-8"/> 
 
\t <xsl:template match="/"> 
 
\t \t <html> 
 
\t \t \t <head> 
 
\t \t \t \t <title> 
 
\t \t \t \t \t <xsl:value-of select="versions/project" /> 
 
\t \t \t \t </title> 
 
\t \t \t \t <style type="text/css"> 
 
\t \t \t \t \t ... 
 
\t \t \t \t </style> 
 
\t \t \t </head> 
 
\t \t \t <body> 
 
\t \t \t \t <div class="content"> 
 
\t \t \t \t \t 
 
\t \t \t \t \t \t \t \t <xsl:for-each select="/releasenotes/notes/note[component/@type=$unitTag]"> 
 
\t \t \t \t \t \t \t \t \t <xsl:for-each select=".[component/@number=$versionNumber and text/@type='new']"> 
 
\t \t \t \t \t \t \t \t \t \t <li type="disc"> 
 
\t \t \t \t \t \t \t \t \t \t \t <xsl:value-of select="text" /> 
 
\t \t \t \t \t \t \t \t \t \t \t <xsl:for-each select="component[not(@type=$unitTag)]"> 
 
\t \t \t \t \t \t \t \t \t \t \t \t <xsl:sort select="@type" order="ascending"/> 
 
\t \t \t \t \t \t \t \t \t \t \t \t , <a href="#{@type}_{@number}"> 
 
\t \t \t \t \t \t \t \t \t \t \t \t \t <xsl:variable name="unitType" select="@type"/> 
 
\t \t \t \t \t \t \t \t \t \t \t \t \t <xsl:value-of select="//components/component[tag=$unitType]/name" />&#160;(<xsl:value-of select="@number" />) 
 
\t \t \t \t \t \t \t \t \t \t \t \t </a> 
 
\t \t \t \t \t \t \t \t \t \t \t </xsl:for-each> 
 
\t \t \t \t \t \t \t \t \t \t </li> 
 
\t \t \t \t \t \t \t \t \t </xsl:for-each> 
 
\t \t \t \t \t \t \t \t </xsl:for-each> 
 
\t \t \t \t \t \t \t 
 
\t \t \t \t \t \t </xsl:for-each> 
 
\t \t \t \t \t </xsl:for-each> 
 
\t \t \t \t \t 
 
\t \t \t \t </div> 
 
\t \t \t </body> 
 
\t \t </html> 
 
\t </xsl:template> 
 
</xsl:stylesheet>
問題は、この行であると思われる問題を回避するために

Expected token 'EOF' found '['. .-->[<--component/@number='$versionNumber' and text/@type='new'] 

答えて

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']"> 
1

、その特定の.を交換しよう同等の、短縮されていないe xpress、self::node()を使用すると、XSLはブラウザ間で動作します。 XPathの述語の後に省略ステップ(...)に関する関連の最近の質問:その代わり

<xsl:for-each select="/releasenotes/notes/note[component/@type=$unitTag]"> 
    <xsl:for-each select=".[component/@number=$versionNumber and text/@type='new']"> 

Selenium WebDriver Xpath current element attribute reports invalid Xpath exception

1

たいようです.[condition]はXPath 1.0の文法では許可されていないので、IEはそれを拒否するのは正しいです。

あなたが実際に

<xsl:if test="condition"> 

やマーティンHonnenにより示唆されるように、親xsl:for-eachにそれを組み合わせると

<xsl:for-each select=".[condition]"> 

を置き換えることができます。