XSLT wont allow me to use self-closing img and br tags

前端 未结 3 2161
忘掉有多难
忘掉有多难 2020-12-11 03:37

I have some XSLT that gets rendered in the Sitecore 6 CMS, but I don\'t think that this issue is specific to the product.

If I have a self-closing img or br tag, lik

相关标签:
3条回答
  • 2020-12-11 04:15

    That is just fine. You choose HTML, and <br> tags are allowed in HTML. Choose XML and then you will have what you want.

    And yes, you should use XML method if you want self-closing tags. I'm guessing you want XHTML output, and XHTML is a XML document.

    0 讨论(0)
  • 2020-12-11 04:17

    On the top of your stylesheet you can specify to use XML as the output format and you can also set a specific DOCTYPE, for example:

    <xsl:output method="xml" 
        media-type="text/html" 
        doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
        doctype-system="DTD/xhtml1-strict.dtd"
        cdata-section-elements="script style"
        indent="yes"
        encoding="UTF-8"/>
    
    0 讨论(0)
  • 2020-12-11 04:20

    When you do get self closing tags working, you may run accross some odd bugs. Here are some examples:

    A couple years ago in IE, I my whole rendered page was blank, but view source showed the full HTML. The problem was a self closing title tag (<title/>).

    Also, self closing script tags (<script src="code.js"/>) can cause the JavaScript files not to load, so inside of your XSLT, you may need to have some text inside the script tag to keep it from self closing and get it to work.

    <script src="code.js>//</script>
    
    0 讨论(0)
提交回复
热议问题