Reputation: 149
I am trying to generate a relative URL with a complex query string using XSLT 1.0 stylesheets (processed by the web browser).
<xsl:variable name="queryLn">sql</xsl:variable>
<xsl:variable name="queryName">ask</xsl:variable>
<a>
<xsl:attribute name="href">
<xsl:text>path?action=exec&queryLn=</xsl:text>
<xsl:value-of select="$queryLn" />
</xsl:attribute>
<xsl:value-of select="$queryName" />
</a>
I have altered how the variables get assigned for simplicity. In the real code, they get assigned similar values from the XML being transformed. I want the resulting document to contain this:
<a href="path?action=exec&queryLn=sql>ask</a>
Chrome Browswer gives me an error message like error on line XX at column YY: EntityRef: expecting ';'
, where XX and YY refer to immediately after the <xsl:text>
opening tag. I've tried adding a disable-output-escaping="yes"
attribute to the <xsl:text>
element, but that doesn't have any effect.
What am I doing wrong?
Upvotes: 2
Views: 862
Reputation: 243459
Use:
<a href="path?action=exec&queryLn={$queryLn}"><xsl:value-of select="$queryName"/></a>
Your code has these problems:
Unescaped &
-- must be &
.
Unnecessary <xsl:attribute>
-- it is recommended that one uses AVT -s (Attribute - Value Templates) always when possible.
Upvotes: 1
Reputation: 149
Firefox gave a much more useful error message that pointed me in the right direction.
It turns out this was invalid XML. &
needed to be &
.
Upvotes: 0