Copied to clipboard

Flag this post as spam?

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


  • Adam 7 posts 27 karma points
    Jun 15, 2011 @ 05:14
    Adam
    0

    xslt shows first child node repeated instead of each individually

    Hi I have a quick question about showing child nodes.

    I'm trying to dynamically create a select list which seems very simple, but the xslt keeps outputting the first child node until it hits the max number of child nodes to show. I can't figure out how to check if a child node has already been processed and if so, move onto the next.

    Thanks in advance for any help.

    <?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" 
        exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">
    
    
    <xsl:output method="xml" omit-xml-declaration="yes"/>
    
    <xsl:param name="currentPage"/>
    <xsl:variable name="SortOrder" select="$currentPage/data[@alias = 'languagesSortOrder']" />  
    <xsl:variable name="SortBy" select="$currentPage/data[@alias = 'languagesSortBy']" />
    <xsl:variable name="NumberofLanguages" select="$currentPage/data[@alias = 'numberLanguages']" />
    
    <xsl:template match="/">
    
    <!-- We need to set data-type to number or text depending on what sortby equals -->
    <xsl:variable name="DataType">  
        <xsl:choose>  
            <xsl:when test="$SortBy='sortOrder'">  
                <xsl:value-of select="'number'" />  
            </xsl:when>  
            <xsl:otherwise>  
                <xsl:value-of select="'text'" />  
            </xsl:otherwise>  
        </xsl:choose>  
    </xsl:variable>
    
    <div id="multilingual">
    
    <h2><xsl:value-of select="$currentPage/data [@alias='multilingualCaption']"/></h2>
        <form id="form-multilingual" method="get" action="#">
            <select id="select-multilingual">
                <option>Choose your language</option>
    
                <xsl:for-each select="$currentPage/descendant::node[@nodeName = 'Languages']/node[string(data [@alias='umbracoNaviHide']) = '0']">
                    <!--order="{$SortOrder}" -->
                    <xsl:sort select="@*[name() = $SortBy]" order="{$SortOrder}" data-type="{$DataType}"/>
    
                        <xsl:if test="position()&lt;= $NumberofLanguages">
                         <option value="{$currentPage/descendant::node/data[@alias='languageURL']}"><xsl:value-of select="$currentPage/descendant::node/data[@alias='languageCaption']" /></option>
                        </xsl:if>
    
                </xsl:for-each>
    
            </select>
        </form>
        <img src="{$currentPage/data [@alias='multilingualPic']}" alt="{$currentPage/data [@alias='multilingualCaption']}" />
    
    </div>
    
    </xsl:template>
    
    </xsl:stylesheet>
  • 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