Copied to clipboard

Flag this post as spam?

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


  • Kasper Dyrvig 246 posts 379 karma points
    Aug 09, 2010 @ 13:56
    Kasper Dyrvig
    0

    XSLT totally ruins my design

    I'm tring to make a sort of dynamic breadcrumb with XSLT. But until now it tottaly ruins my design. It's like it doesn't close all the tags correctly.

    On my template I have:

    <div id="divTopWrap">
      <div id="divBreadcrumb">
        <div style="clear: left; margin-top: -4px;">
          <div class="breadcrumbItem">
            Her er du:
          </div>
          <div class="breadcrumbItem">
              <a href="/Forside">Forside</a>
          </div>
          <umbraco:Macro Alias="DynamicBreamcrumb" runat="server"></umbraco:Macro>
          <div class="breadcrumbItem">
            <span class="breadcrumbCurrent"><xsl:value-of select="pageTitle"/></span>
          </div>
        </div>
    </div>
    </div>

    In the XSLT I have some more...

    <div class="breadcrumbItem">
                <a href="#">Dropdown 1 here</a>
            </div><div class="breadcrumbItem">
              <a href="#">Dropdown 2 here</a>
          </div>

    I have validated my css, and there is no errors.

    But still it is like XSLT smash it. Anyone who have an idea of what to do?

  • Steen Tøttrup 191 posts 291 karma points c-trib
    Aug 09, 2010 @ 14:03
    Steen Tøttrup
    0

    What does the html output look like ??

     

  • Per Ploug 865 posts 3491 karma points MVP admin
    Aug 09, 2010 @ 14:12
    Per Ploug
    1

    xslt merges all empty tags so

    becomes <div></div> becomes <div/>

     

     

    change the output to html instead of xml:

    <xsl:output method="html" omit-xml-declaration="yes"/>
  • Kasper Dyrvig 246 posts 379 karma points
    Aug 09, 2010 @ 14:41
    Kasper Dyrvig
    0

    Thank you!

  • Steen Tøttrup 191 posts 291 karma points c-trib
    Aug 09, 2010 @ 14:46
    Steen Tøttrup
    0

    That might give you some other issues, but if it solves your problem....

     

  • Kasper Dyrvig 246 posts 379 karma points
    Aug 09, 2010 @ 15:15
    Kasper Dyrvig
    0

    Problems... Like what?

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Aug 09, 2010 @ 15:16
    Stefan Kip
    0

    XSLT is evil ;-)

  • Per Ploug 865 posts 3491 karma points MVP admin
    Aug 09, 2010 @ 15:24
    Per Ploug
    0

    Setting output method to html will make xslt generate html instead of xml elements, this generally will not cause you any issues if you expect html, however, it will also force a tag like <br/> to be rendered as <br> so that will not be valid xhtml. 

    So if steen and kiposoep doesn't have real problems  to tell you about ;)  then I'm pretty confident it will solve your problem considering the snippet you posted  

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Aug 09, 2010 @ 15:27
    Stefan Kip
    0

    @Per

    :O :O :O

    Real problems?! Lol :D
    XSLT == evil. Whatever output you choose, it fails anyway :P

  • Per Ploug 865 posts 3491 karma points MVP admin
    Aug 09, 2010 @ 15:30
    Per Ploug
    0

    @kipusoep, the problem must be somewhere else: http://www.amazon.com/XSLT-Dummies-Richard-Wagner/dp/0764536516 ;-)

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Aug 09, 2010 @ 15:34
    Stefan Kip
    0

    Haha okay, then tell me how I should tell XSLT not to output <div /> out of <div></div> without using <div>&nbsp;</div> hack.

    Whilst <br /> won't be transformed to <br>... :D

  • Arjan den Boer 76 posts 31 karma points
    Aug 09, 2010 @ 16:02
    Arjan den Boer
    0

    <div><xslt:text>
    </xslt:text></div>

    ...is a bit better then <div>&nbsp;</div> because it's considered an empty tag by browsers.

    It's even valid XHTML when used in an <ul> while &nbsp; is not allowed,

     

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Aug 09, 2010 @ 16:11
    Stefan Kip
    0

    Sounds like a hack/work-around to me ;-)

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Aug 09, 2010 @ 16:33
    Sebastiaan Janssen
    2

    It's a workaround indeed, I always use <xsl:comment /> which will then output <!-- --> for you so that the tag cannot auto-close AND I do not have the risk of a stray space screwing up my layout.

  • Steen Tøttrup 191 posts 291 karma points c-trib
    Aug 09, 2010 @ 17:29
    Steen Tøttrup
    0

    That or use xml:space="preserve" in the xsl:template tag, then white-spaces will be left in the output, that way a <div> </div> wont end up as<div />

    I don't ever do html output in the solutions I make, everything is xhtml these days, so output="html" really isn't an option for me.

     

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Aug 09, 2010 @ 18:06
    Sebastiaan Janssen
    0

    There's two problems with preserving whitespace: 

     

    1. You can't apply it to the xsl:template tag, you have to apply it to individual elements that need preserving of whitespace
    2. You would still have to remember to put some whitespace there in the first place, most of the time I just get a blob of html from the frontend designer and they haven't put spaces in there (which is actually a good thing). So you're back to square one.

     

Please Sign in or register to post replies

Write your reply to:

Draft