Copied to clipboard

Flag this post as spam?

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


  • Garry Bain 149 posts 124 karma points
    Oct 27, 2009 @ 17:18
    Garry Bain
    0

    Closing an image in XSLT (page not validating)

    Hi,

    I wish to insert an inline image into my XSLT file - but my source code shows that the image is not closing itself properly. My XSLT is:

           <a href="{umbraco.library:NiceUrl(@id)}">
                <img src="/images/more.jpg" alt="Read more" id="readmore"/>
            </a>

    But the output of this code looks like:

    <a href="/news/brand-new-site-for-essex-ice.aspx"><img src="/images/more.jpg" alt="Read more" id="readmore"></a>

    As you can see at the very end - the image is not closed properly and there causing a validation error, I need this image to be inline as it will link to my news items.

    Cheers, Garry.

  • Lee Kelleher 4026 posts 15837 karma points MVP 13x admin c-trib
    Oct 27, 2009 @ 17:41
    Lee Kelleher
    0

    Hi Garry,

    The quickest way is to change the output method:

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

    This will automatically convert all your HTML to XML.  Beware of any empty HTML tags you might have... as:

    <div></div>

    will become:

    <div/>

    Cheers, Lee.

  • dandrayne 1138 posts 2262 karma points
    Oct 27, 2009 @ 17:47
    dandrayne
    0

    As an addition to Lee's point, it's a bit hacky but

    <div>&#160;</div>

    Puttin &#160; inside your divs will create a nbsp and keep the div from self-closing

    Dan

  • Garry Bain 149 posts 124 karma points
    Oct 27, 2009 @ 17:48
    Garry Bain
    0

    My output method is already

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

    This is defined in the XSLT file isn't it?

    Garry.

  • Garry Bain 149 posts 124 karma points
    Oct 27, 2009 @ 17:51
    Garry Bain
    0

    Oops - sorry I was looking in the wrong XSLT file

    That's done it, I don't use empty div's for anything unless I'm really being "hacky" - but I'll note it down for future reference.

    Thanks very much, Garry.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies