I'm going through the w3cschools XSLT tutorial, and I am at this page: xsl-if.
On that page (in red) is the text <xsl:if test="price > 10">
. This works. I modified the code to use "<"
and that works fine too.
I tested <xsl:if test="price > 10">
(note the use of >
instead of the >
). This works too.
But this fails: <xsl:if test="price < 10">
. Error is XML Parsing Error: not well-formed
and it points to the <
symbol in the expression.
If the >
symbol worked fine, why did using the <
fail? (I'm using FireFox)
If the > symbol worked fine, why did using the < fail? (I'm using FireFox)
Because the "<" character is one of the few that are illegal within an attribute value (it is the start-of tag character).
From the XML Specification
[10] AttValue ::= '"' ([^<&"] | Reference)* '"'
As can be clearly seen, the "<" and "&" characters are not allowed in any attribute value.
Update: As noticed by @Tomalak, the above should read:
As can be clearly seen, the "<" and "&" characters (unless the latter is part of an entity reference or character reference) are not allowed in any attribute value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With