我正在通过“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