What is the proper way to use a literal close brace within an
expression inside an attribute value template?
<e a="{substring-before($v, '}')}"/>
The spec says:
http://www.w3.org/TR/xslt#attribute-value-templates
A right curly brace inside a Literal in an expression is not
recognized as terminating the expression.
But this does not seem to be the case. In the example below, a
substring-before() invocation using '{' works, but using '}' gives
an error.
% cat /tmp/x.xsl
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:variable name="v" select=""before{during}after""/>
<xsl:template match="/">
<top>
<e a="{substring-before($v, '{')}"/>
</top>
</xsl:template>
</xsl:stylesheet>
% echo '<in/>' | xsltproc /tmp/x.xsl -
<?xml version="1.0"?>
<top><e a="before"/></top>
% sed "s/'{'/'}'/" /tmp/x.xsl > /tmp/y.xsl
% cat /tmp/y.xsl
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:variable name="v" select=""before{during}after""/>
<xsl:template match="/">
<top>
<e a="{substring-before($v, '}')}"/>
</top>
</xsl:template>
</xsl:stylesheet>
% echo '<in/>' | xsltproc /tmp/y.xsl -
XPath error : Unfinished literal
compilation error: file /tmp/y.xsl line 6 element e
Attribute 'a': Failed to compile the expression 'substring-before($v, '' in
the AVT.
%
The same section of the spec says:
When an attribute value template is instantiated, a double left or
right curly brace outside an expression will be replaced by a
single curly brace. It is an error if a right curly brace occurs
in an attribute value template outside an expression without being
followed by a second right curly brace.
So using double braces ("}}") should not work, since the
doubling-as-escape only works outside expressions. I tested it and
it also fails, since the expression is terminated on the first close
brace.
My take is that this is a bug in libxslt, but I'd like
confirmation before I start working up a fix.
Thanks,
Phil
_______________________________________________
xslt mailing list, project page http://xmlsoft.org/XSLT/
[email protected]
http://mail.gnome.org/mailman/listinfo/xslt