xsl transform: problem with Ampersand URL parameters

Posted by Rac123 on Stack Overflow See other posts from Stack Overflow or by Rac123
Published on 2010-05-25T21:04:14Z Indexed on 2010/05/25 21:11 UTC
Read the original article Hit count: 237

Filed under:
|

I'm having issues with transforming XSL with parameters in a URL. I'm at a point that I can't change the C# code anymore, only can make changes to xsl file.

C# code:

string xml = "<APPLDATA><APPID>1052391</APPID></APPLDATA>";

XmlDocument oXml = new XmlDocument();
oXml.LoadXml(xml);

XslTransform oXslTransform = new XslTransform();
oXslTransform.Load(@"C:\Projects\Win\ConsoleApps\XslTransformTest\S15033.xsl");

StringWriter oOutput = new StringWriter();
oXslTransform.Transform(oXml, null, oOutput)

XSL Code:

  <body>
    <xsl:variable name="app">
      <xsl:value-of select="normalize-space(APPLDATA/APPID)" />
    </xsl:variable>
    <div id="homeImage" >
      <xsl:attribute name="style">
        background-image:url("https://server/image.gif?a=10&amp;Id='<xsl:value-of disable-output-escaping="yes" select="$app" />'")
      </xsl:attribute>

    </div>
  </body>
</html>

URL transformed: https://server/image.gif?a=10&Id='1052391'

URL Expected: https://server/image.gif?a=10&Id='1052391'

How do I fix this? The output (oOutput.ToString()) is being used in an email template so it's taking the URL transformed literally. When you click on this request (with the correct server name of course), the 403 (Access forbidden) error is being thrown.

© Stack Overflow or respective owner

Related posts about xslt

Related posts about xsl