开发者

using symbols in xsl

i am using symbols > in xsl file , which work but when i am using like <= it shows nothing.

can anybody tell me , whats wrong with it <= and which alternat开发者_StackOverflow社区ive should i use?

<xsl:if test="price &lt; 100">
<xsl:if test="price > 100">


An XSLT stylesheet must be a well-formed XML document. This is why the < character (and the & character) has to be escaped always when they are not in a CDATA section.

Use either:

<xsl:if test="price &lt;= 100"> 

or, if you don't like escaping:

<xsl:if test="not(price > 100)"> 


The W3C XML spec says that a literal < is not allowed in an attribute (> is OK):

The replacement text of any entity referred to directly or indirectly in an attribute value must not contain a <.

So in the test attribute, you need to escape <. If your condition is price <= 100 then you would write it as:

<xsl:if test="price &lt;= 100">


You should escape < to &lt;, as you have in your first code example.

The > escape is &gt;.

You should escape characters that have special meaning in XML - these are <>"'&.

Though in attributes, using > is fine.

See this SO question and answers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜