Copied to clipboard

Flag this post as spam?

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


  • Bas Wensveen 54 posts 75 karma points
    Jun 04, 2010 @ 14:06
    Bas Wensveen
    0

    XSLT unexpected html code

    Hi

     

    I wrote a xslt script to setup a image gallery for fancybox. The script generates the html as expected by does something extra. After the html elements needed for fancybox a link element is generated after every html element from where the script is called.

    See the html code below. The bold ones are unexpected. I also added the whole xslt script. 

     

    Anyhelp appreciated.

     

        <ul id="FotoAlbums">
          <li>
            <div id="wrapper">
                <a href="/media/397/blauwe%20heuvels.jpg" class="element_groep" rel="Snertpop 2008">
                <img src="/umbraco/ImageGen.ashx?image=/media/397/blauwe%20heuvels.jpg&amp;width=124&amp;height=90&amp;compression=100&amp;fontsize=11&amp;fontcolor=white&amp;FontStyle=Bold&amp;align=center%22" alt="Foto 1"></a>
              <div class="description">Snertpop 2008</div>
            </div>
          </li>
            <a class="element_groep" rel="Snertpop 2008" href="/media/397/blauwe%20heuvels.jpg"></a>
            <a class="element_groep" rel="Snertpop 2008" href="/media/397/blauwe%20heuvels.jpg"></a>
          <li>
            <div id="wrapper">
                <a href="/media/630/winter.jpg" class="element_groep" rel="Snertpop 2009">
                    <img src="/umbraco/ImageGen.ashx?image=/media/630/winter.jpg&amp;width=124&amp;height=90&amp;compression=100&amp;fontsize=11&amp;fontcolor=white&amp;FontStyle=Bold&amp;align=center%22" alt="Foto 3">
                </a>
              <div class="description">Snertpop 2009</div>
            </div>
          </li>
          <a class="element_groep" rel="Snertpop 2009" href="/media/630/winter.jpg"></a>
          <a class="element_groep" rel="Snertpop 2009" href="/media/630/winter.jpg"></a>
        </ul>
        <a class="element_groep" rel="Snertpop 2009" href="/media/630/winter.jpg"></a>
    <p>
    <a class="element_groep" rel="Snertpop 2009" href="/media/630/winter.jpg">Fotoboek body tekst</a>
    </p>
    <a class="element_groep" rel="Snertpop 2009" href="/media/630/winter.jpg"></a>

     

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [
        <!ENTITY nbsp "&#x00A0;">
    ]>
    <xsl:stylesheet
        version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:msxml="urn:schemas-microsoft-com:xslt"
        xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:Designit.VideoEmbed="urn:Designit.VideoEmbed"
        exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets Designit.VideoEmbed ">
    
        <xsl:output method="xml" omit-xml-declaration="yes" />
    
        <xsl:param name="currentPage"/>
    
        <!-- Input the documenttype you want here -->
        <xsl:variable name="documentTypeAlias" select="string('FotoAlbum')"/>
    
        <xsl:template match="/">
    
            <xsl:variable name="rootNode" select="$currentPage/ancestor-or-self::node[last()] "/>
    
            <ul id="FotoAlbums">
                <!-- list all photoalbums  -->
                <xsl:for-each select="$rootNode/descendant-or-self::node [@nodeTypeAlias = $documentTypeAlias ]">
                    <xsl:choose >
                        <xsl:when test="current()  != '' ">
                            <!-- store the current photo album node for fancy box image grouping -->
                            <xsl:variable name="currentNode" select="current()"></xsl:variable>
    
                            <!-- setup the clickable thumbnail for the fancy box gallery to start-->
                            <li >
                                <div id="wrapper">
                                    <a>
                                        <xsl:attribute name="href">
                                            <xsl:value-of select="./node/data [@alias='umbracoFile']"/>
                                        </xsl:attribute>
                                        <xsl:attribute name="class">element_groep</xsl:attribute>
                                        <xsl:attribute name="rel">
                                            <xsl:value-of select="./@nodeName"/>
                                        </xsl:attribute>
                                        <img>
                                            <xsl:attribute name="src">
                                                <xsl:text>/umbraco/ImageGen.ashx?image=</xsl:text>
                                                <xsl:value-of select="./node/data [@alias='umbracoFile']" />
                                                <xsl:text>&amp;width=124&amp;height=90&amp;compression=100</xsl:text>
                                                <xsl:text>&amp;fontsize=11&amp;fontcolor=white&amp;FontStyle=Bold&amp;align=center"</xsl:text>
                                            </xsl:attribute>
                                            <xsl:attribute name="alt">
                                                <xsl:value-of select="./node/@nodeName"/>
                                            </xsl:attribute>
                                        </img>
                                    </a>
                                    <div class="description">
                                        <xsl:value-of select="./@nodeName"/>
                                    </div>
                                </div>
                            </li>
    
                            <!-- Get all photo's from this gallery -->
                                <xsl:for-each select="$currentNode/descendant-or-self::node [@nodeTypeAlias = 'Foto'  and $currentNode/descendant-or-self::node != '']">
                                    <xsl:element name="a" >
                                        <xsl:attribute name="class">element_groep</xsl:attribute>
                                        <xsl:attribute name="rel">
                                            <xsl:value-of select="$currentNode/@nodeName"/>
                                        </xsl:attribute>
                                        <xsl:attribute name="href">
                                            <xsl:value-of select="$currentNode/node/data [@alias='umbracoFile']"/>
                                        </xsl:attribute>
                                    </xsl:element>
                                </xsl:for-each>
    
                        </xsl:when>
                        <xsl:otherwise>
                            <img src="/css/images/GeenFotoBeschikbaar.jpg" alt="Geen foto album beschikbaar"/>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:for-each>
            </ul>
        </xsl:template>
    
    </xsl:stylesheet>

     

  • Richard 146 posts 168 karma points
    Jun 04, 2010 @ 14:31
    Richard
    0

    Are you sure that the XSLT is generating the content in the P tag, as this is after the close of the <ul id="FotoAlbums">, which is at the end of the XSLT template?

    <p>
    <a class="element_groep" rel="Snertpop 2009" href="/media/630/winter.jpg">Fotoboek body tekst</a>
    </p>
  • Bas Wensveen 54 posts 75 karma points
    Jun 05, 2010 @ 08:20
    Bas Wensveen
    0

    Hi Richard,

     

     

    I see it in firebug. The HTML above is copied from there.

     

     

  • Bas Wensveen 54 posts 75 karma points
    Jun 05, 2010 @ 08:27
    Bas Wensveen
    0

    Richard,

     

    Ik have to be more precise, the p element is in the HTML template that call the xslt. I think it is what the browser does when there is some bug in the xslt.

     

     

  • Bas Wensveen 54 posts 75 karma points
    Jun 13, 2010 @ 21:22
    Bas Wensveen
    0

    Hi all,

     

    I still not have a solution for the problem I face described above. Really appreciate any help. I could give you the link of the website, then can you see the HTML that is generated. 

     

    Kind regards,

     

    Bas

     

  • Tommy Poulsen 514 posts 708 karma points
    Jun 13, 2010 @ 21:55
    Tommy Poulsen
    0

    Hi Bas,

    without investigating your snippet in detail, it seems as if you output <a>-tags within you <ul>...</ul> section whithout embedding them in <li>...</li> tags.

    I.e. this code

    <!-- Get all photo's from this gallery -->
          <xsl:for-each
    ...
          </xsl:for-each>

    should probably eithe be moved, removed or embedded within <li>..</li> tags

    >Tommy

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Jun 13, 2010 @ 22:15
    Morten Bock
    0

    Try using the "View source" instead of the firebug console. The console will give you the interpreted html, and not the actual source. So if you f.ex. have an invalid element somewhere like <a />, then firebug will show you how firefox tries to correct that error.

    The View Source might give you a more accurate output to debug from. You could copy it here as well, so we can investigate further.

Please Sign in or register to post replies

Write your reply to:

Draft