Copied to clipboard

Flag this post as spam?

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


  • Jesper Ordrup 1019 posts 1528 karma points MVP
    Jun 26, 2009 @ 08:05
    Jesper Ordrup
    0

    Problem with XSLT changing output

    Hi all,

    I'm having a big issue with my 4.0.2.1 installation. I've got several xslt macro's that seems to change the output.  Initially the xslt output type was  'html'. This because then you don't have to worry about empty tags being collapsed and thereby causing problems for your css. Problem is that I found xslt to change some tags. Examples:

    <input type="hidden" value="3333" name="horse" id="horse"/>

      becomes:

    <input type="hidden" value="3333" name="horse" id="horse">

    ... without closing the tag with /. The html doctype is xhtml 1.0 strict and this would of course mean that the page no longer validates.

    Changing the output type to XML changed this. Though now I have to identify collapsed tags causing some problems. Like <textarea></textarea>

    Has anyone else seen this? Now the cure? Any hints is much appreciated.

    /Jesper Ordrup

  • Jamie Pollock 27 posts 102 karma points c-trib
    Jun 26, 2009 @ 09:41
    Jamie Pollock
    101

    Hi Jesper,

    I've tried the following although it may not be what you're looking for exactly, the output is set to xml but that shouldn't matter for this:

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

    And for dynamic properties (below I've added a variable to rows) you can break the xsl:text like so:

    <xsl:text disable-output-escaping="yes"><![CDATA[<textarea rows="]]></xsl:text><xsl:value-of select="$rowSize" disable-output-escaping="yes" /><xsl:text disable-output-escaping="yes"><![CDATA["></textarea>]]></xsl:text>

    Admittedly it is quite messy, I hope this helps.

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jun 26, 2009 @ 10:25
    Lee Kelleher
    0

    ... or would swapping the tags around work to? (I haven't tested this btw)

    <textarea><xsl:text><![CDATA[]]></xsl:text></textarea>

    You could put a space in the CDATA, but that would be rendered back to the browser.

    This would make your XSLT more readable if you wanted to add the dynamic properties, like Jamie suggests:

    <textarea rows="{$rowSize}"><xsl:text><![CDATA[]]></xsl:text></textarea>
  • Jamie Pollock 27 posts 102 karma points c-trib
    Jun 26, 2009 @ 10:34
    Jamie Pollock
    0

    Hi Lee,

    That solution unfortunately does not work, which is a shame because it does look a lot cleaner.

    good effort :)

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Jun 26, 2009 @ 11:02
    Ismail Mayat
    1

    Jesper,

    The compliance filter stuff i put on codeplex does fix this sort of thing see here i do have a newer version ping me if you need it.  It may be overkill but it will for example take <img src="blah.gif"> and give you <img src="blah.gif"/> it will also fix other self closing tags that have not been closed.  There a couple of issues with it mainly to do the asp.net ajax but you wont know until you try it.

    Regards


    Ismail

  • Gerty Engrie 130 posts 490 karma points c-trib
    Jun 26, 2009 @ 11:06
    Gerty Engrie
    0

    if your output type still is xml you can just do: <input type="hidden" value="3333" name="horse" id="horse"></input>  i think, xml will close it itself because there is no content between the tags :)

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Jun 26, 2009 @ 12:32
    Ismail Mayat
    0

    Gerty,

    The xslt wont self close it, the output will be <input type="hidden" value="3333" name="horse" id="horse"></input>

    Regards


    Ismail

  • Jesper Ordrup 1019 posts 1528 karma points MVP
    Jun 26, 2009 @ 15:21
    Jesper Ordrup
    0

    Thanks for the good tips. I added a space between and a jquery that removes it :-)

    @Ismail: the compliance http module sounds violent but it might help me if nothing else works.

    The strange thing is that when outputting html both <input/> and <input></input> becomes <input> . But that might be what is expected - I just didn't.

     

    /Jesper

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Jun 26, 2009 @ 16:03
    Ismail Mayat
    1

    Jesper,

    It is heavy weight but it works and will fix other issues like missing alt tags and .net compliance issues.  If you are going to use it ping me i will send you latest version.

    Regards


    Ismail

Please Sign in or register to post replies

Write your reply to:

Draft