我正在通過「Beginning XSLT 2.0 From Novice to Professional」學習XSLT。繼從書的源代碼,我試圖在Visual Studio 2008 TS編譯此:Visual Studio 2008中的「無效的XPath表達式」錯誤TS
<xsl:template match="Program">
<div>
<p>
<xsl:if test="@flag">
<img src="{if (@flag = 'favorite') then 'favorite' else 'interest'}.gif"
alt="[{if (@flag = 'favorite') then 'Favorite' else 'Interest'}]"
width="20" height="20" />
</xsl:if>
<!-- ... -->
</p>
</div>
</xsl:template>
的XML數據如下:
<Channel>
<Name>BBC1</Name>
<Program rating="5" flag="favorite">
<!-- ... -->
</Program>
<!-- ... -->
</Channel>
然而,當我編譯這段代碼我得到:
'string(if (@flag = 'favorite') then 'favorite' else 'interest')' is an invalid XPath expression.
我檢查了這本書的網站尋找勘誤,不幸的是這並沒有被覆蓋。任何指針都會很棒。
@Eval_Penguin:請不要將'折磨自己 「<」''以 「<」'。您可以使用「0101」代碼格式編輯器按鈕,也可以使用四個空格縮進代碼塊。你甚至會得到免費的語法高亮。 ;-) – Tomalak 2009-09-30 11:29:01