I am trying to generate URLs from a base XML file via XSLT using Saxon 9. However, the resulting URLs are to be used for a GET HTTP request (executed via Java, following the generation), and will contain ampersands ('&') to delimit parametres.
I wrote the XSLT to make the conversion, which worked when using Eclipse to test.
Code : <xsl:text disable-output-escaping="yes">&month=</xsl:text>
However, running the same XSLT file using Saxon with Java, it doesn't behave the same. It instead inserts the escape code & into the generated URL.
I tried using an XSLT variable instead, but the result was the same. Neither of the following attempts worked.
<xsl:variable name="and"><![CDATA[&]]></xsl:variable>
<xsl:variable name="and" select="'&'" />
I also saw that a solution for C# is to have a variable with the value &amp;, but this did nothing in Java other than to insert that text literally into the generated URL.
So my question is : is it possible to have an unescaped ampersand generated via XSLT? Or will I have to generate an escaped character string and then do a substitution later in Java?
And if it is not possible (due to XML not allowing unescaped ampersands), how is it that Eclipse could generate it, whereas Saxon cannot?
output method="text") or HTML document (output method="html") or an XML document (output method="xml")? Inside HTML or XML the ampersand needs to be escaped.