加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

xml – 在xpath中为什么我可以使用大于符号>但不小于<

发布时间:2020-12-15 23:54:17 所属栏目:百科 来源:网络整理
导读:使用c#3编译变换以下似乎工作得很好…… xsl:choose xsl:when test="$valA $valB" xsl:value-of select="$maxUnder" / /xsl:when xsl:when test="$valA lt; $valC" xsl:value-of select="$maxOver" / /xsl:when/xsl:choose 但是,如果我敢于使用代替 lt;它给
使用c#3编译变换以下似乎工作得很好……
<xsl:choose>
    <xsl:when test="$valA > $valB">
        <xsl:value-of select="$maxUnder" />
    </xsl:when>
    <xsl:when test="$valA &lt; $valC">
        <xsl:value-of select="$maxOver" />
    </xsl:when>
</xsl:choose>

但是,如果我敢于使用<代替& lt;它给出了一个错误......

<xsl:choose>
    <xsl:when test="$valA > $valB">
        <xsl:value-of select="$maxUnder" />
    </xsl:when>
    <xsl:when test="$valA < $valC">
        <xsl:value-of select="$maxOver" />
    </xsl:when>
</xsl:choose>

System.Xml.XmlException: ‘<‘,
hexadecimal value 0x3C,is an invalid
attribute character.

那么为什么>好的而不是< ?

因为>不是XML中的保留字符,但是<是. 从 section 2.4 of the XML 1.0 spec (5th edition)开始:

The ampersand character (&) and the
left angle bracket (<) must not appear
in their literal form,except when
used as markup delimiters,or within a
comment,a processing instruction,or
a CDATA section. If they are needed
elsewhere,they must be escaped using
either numeric character references or
the strings “&amp;” and “&lt;
respectively. The right angle bracket
(>) may be represented using the
string “&gt;“,and must,for
compatibility,be escaped using either
&gt;” or a character reference when
it appears in the string “]]>” in content,when that string is not marking the end of a CDATA section.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读