xslt, javascript and unescaped html entities

前端 未结 5 722
遇见更好的自我
遇见更好的自我 2020-11-30 14:48

i have a tiny little problem with xslt, js and html entities, eg. within a template:



        
5条回答
  •  一个人的身影
    2020-11-30 15:10

    i always thought the xslt processor would leave the content of a script element unescaped when using the html output method

    You are correct: http://www.w3.org/TR/xslt#section-HTML-Output-Method

    The html output method should not perform escaping for the content of the script and style elements.
    For example, a literal result element written in the stylesheet as
        
    or
        
    should be output as
        
    

    If your XSLT processor is doing otherwise, it's a bug.

    However, in any case it's a good idea to avoid '<' and '&' in embedded scripts, and an even better idea to kick all the code out into a linked .js file.

提交回复
热议问题