Copied to clipboard

Flag this post as spam?

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


  • Laura Holland 82 posts 103 karma points
    Mar 31, 2011 @ 02:44
    Laura Holland
    0

    xslt output mystery, extra divs

    I can't figure out why I'm getting a bunch of extra <div>s and <a>s from this stylesheet. Does anyone see anything wrong with it that would cause unexpected output?

    <xsl:template match="/">
        <xsl:variable name="items" select="$currentPage/mainGraphic/DAMP[@fullMedia]/mediaItem/Image"/>
        <!--In "new" multiple media items can be stored with the full media xml.-->
        <xsl:choose>
          <xsl:when test="count($items) &gt; 1">  
            <div class="wt-rotator">
              <div class="screen">
                <noscript>
                  <img src="/media/113/images/img1.jpg" alt="Jerry Rose Floral + Event Planning" />
                </noscript>
              </div>
              <div class="c-panel">
                <div class="buttons">
                  <div class="prev-btn"></div>
                  <div class="play-btn"></div>
                  <div class="next-btn"></div>
                </div>
                <div class="thumbnails">
                  <ul>      
                    <xsl:for-each select="$currentPage/mainGraphic/DAMP[@fullMedia]/mediaItem/Image">
                      <li>
                        <a href="{umbracoFile}" title="Jerry Rose Floral and Event Planning"><img src="{umbracoFile}" /></a>
                      </li>
                    </xsl:for-each>
                  </ul>
                </div>
              </div>
            </div>
          </xsl:when>
          <xsl:otherwise>
            <xsl:for-each select="$currentPage/mainGraphic/DAMP[@fullMedia]/mediaItem/Image">
              <img src="{umbracoFile}" />
            </xsl:for-each>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:template>

    Basically, I'm getting the following extra code that shouldn't be there  (but only from the "when' clause, not the "otherwise"):

    <a href="#"></a>
                </div>
                <a href="#"></a>
            </div>
            <a href="#">
                <div id="footer">
                    JERRY ROSE FLORAL + EVENT DESIGN 176 MAPLEWOOD AVENUE, MAPLEWOOD NJ 07040 TEL +973-762-1085
                    +212-766-5600</div>
            </a>
        </div>

    It's wrapping the footer <div> in an <a>, which it shouldn't be, as well as adding the code above it, which also shouldn't be there. The jquery plugin was working fine until I put the HTML sorrounding the <xsl> elements into the XSLT document (rather than in the template). I moved it into the XSLT document so that when there is only one image, to display it as a static image (rather than through the jquery slideshow).

  • Laura Holland 82 posts 103 karma points
    Mar 31, 2011 @ 02:55
    Laura Holland
    0

    I disabled the jquery to troubleshoot, and it looks like the problem is stemming from the XSLT output.. For some reason it's closing the

    <div class="prev-btn">
  • Laura Holland 82 posts 103 karma points
    Mar 31, 2011 @ 03:00
    Laura Holland
    0

    Fixed it, I think. I just needed to change output mode to html.

  • Kim Andersen 1447 posts 2196 karma points MVP
    Mar 31, 2011 @ 08:19
    Kim Andersen
    0

    Hi Laura

    The code will be messed up because you have some elements with no content in them. Like these:

    <div class="prev-btn"></div>
    <div class="play-btn"></div>
    <div class="next-btn"></div>

    This will cause the code to collapse, if you have the output method set to xml. If you set it to html, this can cause some other problems with some closing tags, so what I'd do is to insert something in the empty tags. You can do this some different ways. Like eg.:

    <div class="prev-btn"><xsl:comment/></div>
    <div class="play-btn"><xsl:text> </xsl:text></div>
    <div class="next-btn">&nbsp;</div>

    /Kim A

Please Sign in or register to post replies

Write your reply to:

Draft