Jump to content

My xsl:if work without using > how is that possible


tojo

Recommended Posts

Hello! Below is listed both the xslt stylesheet and the xml source document.What I find somewhat strange is that I can use this xslt instruction which work fine <xsl:if test="@age > 110">without replacing > for >Can somebody explain that ? Xslt stylesheet****************** <?xml version="1.0" encoding="utf-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/" > <html> <head> <title>Age check on Characters</title> </head> <body> <h3>The recorded age is unusually high. Please check original data.</h3> <xsl:apply-templates select="/Characters/Character" /> </body> </html> </xsl:template> <xsl:template match="Character"> <xsl:if test="@age > 110"> <p> <b><xsl:value-of select="."/></b> is older than expected. Please check if this character's age, <b><xsl:value-of select="@age" /></b> is correct </p> </xsl:if> </xsl:template></xsl:stylesheet> Xml source document***************************<?xml version="1.0" encoding="utf-8" ?><Characters> <Character age="99">Julius Caesar</Character> <Character age="23">Anne Boleyn</Character> <Character age="41">George Washington</Character> <Character age="45">Martin Luther</Character> <Character age="800">Mathuselah</Character> <Character age="119">Moses</Character> <Character age="50">Asterix</Character></Characters>//Tony

Link to comment
Share on other sites

Well any XSLT stylesheet is an XML document so it follows XML syntax rules and with XML the two characters you need to escape are "&" and "<" as "&" respectively "<" as long as they are not used as part of markup (i.e. an character or entity reference with "&" respectively a tag delimiter with "<"). The ">" sign can (and some say) should be escaped but it is not strictly necessary to follow XML well-formedness rules.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...