so what is...">

What's the matter of using `& lt;` instead of just `<` for comparison in XSLT?

Good in XSLT, I often see:

 <xsl:if test="a &gt; b"> 

so what is connected with this?

I mean, I changed it to <xsl:if test="a > b"> and it works .. why not just use this?

+4
source share
4 answers

XSLT files are also XML files; The XML Spec says that you cannot use '<' and '&' in the literal sense, except in certain contexts . Thus, it is a matter of saving well-formed XML in your XSLT file.

+4
source

Nothing to do with XSLT, except that XML and XML prohibit < (but not > ) attribute values:

 $ cat > a.xml <elm a=">"/> $ xmllint a.xml <?xml version="1.0"?> <elm a="&gt;"/> $ cat > b.xml <elm b="<"/> $ xmllint b.xml b.xml:1: parser error : Unescaped '<' not allowed in attributes values <elm b="<"/> ^ b.xml:1: parser error : attributes construct error <elm b="<"/> ^ b.xml:1: parser error : Couldn't find end of Start Tag elm line 1 <elm b="<"/> ^ b.xml:1: parser error : Extra content at the end of the document <elm b="<"/> ^ 
+3
source

I mean, I changed it to <xsl:if test="a < b"> and it works. why not just use this?

If this is true, your so-called "XSLT processor" was not . Any XSLT stylesheet must be a well-formed XML document. Any well-formed XML document cannot contain the character "<" inside the attribute value.

Therefore, please correct the incorrect statement in your question.

+1
source

Because <> are tag delimiters, so we need to avoid this as an object and lt; or or # x 3 e; as a sequence

0
source

All Articles