1

I have javascript code into xslt which should check image dimension. If width is greater than height to rotate img.

<script language="javascript">
    var a = 3;
    var b = 1;
    if (a > b) {
      document.getElementById("img1").style.transform = "rotate(90deg)";
    }  
 </script>  

I tried:

1) &gt;

2) <![CDATA[ --code --]]>

3) disable-output-escaping="yes"

But nothing works. In console see an error message enter image description here

Thanks

kjhughes
  • 106,133
  • 27
  • 181
  • 240

1 Answers1

1

Use &gt; in your XSLT but set

<xsl:output method="html"/>

so that it is serialized as >;

See also

kjhughes
  • 106,133
  • 27
  • 181
  • 240
  • I have already selected one of your links as a dupe. I think you could have done the same – mplungjan Mar 13 '19 at 12:34
  • @mplungjan: At the time of your comment preceding your VTC, I'd already posted this answer without the "See also" links. I thought your duplicate link was good, so I added it and another too, all within initial 4 minutes. No disrespect intended. – kjhughes Mar 13 '19 at 12:39
  • @kjhughes I saw that link "xslt, javascript and unescaped html entities" before and tried everything but it doesn`t work for me. even output as html. – Blade Runner Mar 13 '19 at 13:06
  • @BladeRunner: Are you trying to run your XSLT in the browser, or does your XSLT generate HTML on the server (or offline, batch), which is then sent to the browser? – kjhughes Mar 13 '19 at 13:13
  • @kjhughes none taken – mplungjan Mar 13 '19 at 13:34
  • @kjhughes I tested it with C# program which generates from XSLT -> HTML, and I check this HTML file in the browser. What worries me that even when I use " if (a > b)" XSLT interpreter doesn`t show me an error. And in Browser I see already a formatted symbol. – Blade Runner Mar 13 '19 at 13:49
  • So, all's working when you use `>` directly then? BTW, `>` can be used directly in more contexts than `<` can. See [Simplified XML Escaping](https://stackoverflow.com/questions/1091945/what-characters-do-i-need-to-escape-in-xml-documents/46637835#46637835) – kjhughes Mar 13 '19 at 14:34