Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Andrew Blackmore 84 posts 127 karma points
    Mar 01, 2010 @ 17:39
    Andrew Blackmore
    0

    <br /> and <hr /> is getting changed to <br> and <hr>

    Hi,

     

    I have a few places where I have placed XHTML directly into my xslt macros. It all works fine except for places where I have put a <br /> tag. It needs to self close to stay compliant and for some reason it gets changed to <br> everytime once the content is put into the template. Is there any reason for this and any way I can fix it.

  • dandrayne 1138 posts 2262 karma points
    Mar 01, 2010 @ 17:44
    dandrayne
    1

    Do you have

    <xsl:output method="html" omit-xml-declaration="yes" />

    in your xslt?  This seems to be the behaviour (it's producing html4).  xslt 2.0 has output=xhtml but this doesn't help us much.

    <xsl:output method="xml" omit-xml-declaration="yes" />

    Will fix this issue, but I imagine you've chosen html for a reason.

    Dan

  • Kim Andersen 1447 posts 2196 karma points MVP
    Mar 01, 2010 @ 17:51
    Kim Andersen
    2

    If Dan's idea doesn't work, could you please try to use somethink like this:

    <xsl:text disable-output-escaping="yes"><![CDATA[<br/>]]></xsl:text>

    Actually shouldn't be necessary, but this should work I think.

    /Kim A

  • Andrew Blackmore 84 posts 127 karma points
    Mar 01, 2010 @ 17:52
    Andrew Blackmore
    0

    Hi Dan,

    This is kind of what I was fearing. I honestly don't know too much of a difference between the two outputs but yes, changing the method to xml breaks the macro badly. I might just have to live with a page that doesn't validate. That won't kill me but I'd like to have that work if I can so I'll see what I can do.

  • Andrew Blackmore 84 posts 127 karma points
    Mar 01, 2010 @ 18:24
    Andrew Blackmore
    0

     

    Victory! Thanks a lot Kim.

    I used this code and it works like a charm:

    <xsl:text disable-output-escaping="yes"><![CDATA[<br/>]]></xsl:text>

    Thanks a lot, it finally validates.

     

  • Kim Andersen 1447 posts 2196 karma points MVP
    Mar 02, 2010 @ 09:48
    Kim Andersen
    0

    Great to hear Andrew.

    Glad I could help!

    /Kim A

Please Sign in or register to post replies

Write your reply to:

Draft