Curly brackets inside an attribute value indicate an XPath expression. If characters "{" or "}" should be literally displayed on the output it is necessary to signal to the processor this other meaning (character escaping). This escaping is done by doubling the character: "{" -> "{{" and "}" -> "}}".
|
XSLT
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/> <xsl:template match="/*"> <xxx x="{{" y="{{@r}}" z="{{{@r}}}"/> </xsl:template> </xsl:stylesheet> |
|
|
XML
<aaa r="3"/> |
Output
<xxx x="{" y="{@r}" z="{3}"/> |
| Previous chapter: | Conditional Expressions |
| Next chapter: | Groups |
| Previous page: | Usage of XPath in the attribute values - curly brackets {} |
| Next page: | Creating elements with xsl:element |