Copied to clipboard

Flag this post as spam?

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


  • Daniel Horn 319 posts 344 karma points
    Feb 09, 2011 @ 15:38
    Daniel Horn
    0

    Choose when

    I have this code: but no matter the doc type it just puts the "otherwise" class on it.

                  <href="#">
                    <xsl:choose>
                    <xsl:when test="@nodeTypeAlias='Produkt'">
                    <xsl:attribute name="class">product </xsl:attribute>
                    </xsl:when>
                    <xsl:otherwise>
                    <xsl:attribute name="class">product lagervarer</xsl:attribute>
                    </xsl:otherwise>
                    </xsl:choose>
                   </a>

    Here is the whole xslt:

    <?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:PS.XSLTsearch="urn:PS.XSLTsearch" 
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets PS.XSLTsearch ">
    <xsl:output method="xml" omit-xml-declaration="yes"/>
    <xsl:param name="currentPage"/>
    <xsl:template match="/">
    <xsl:for-each select="umbraco.library:GetXmlAll()/descendant-or-self::* [@isDoc][string(featured) = '1' ]">
                  <href="#">
                    <xsl:choose>
                    <xsl:when test="@nodeTypeAlias='Produkt'">
                    <xsl:attribute name="class">product </xsl:attribute>
                    </xsl:when>
                    <xsl:otherwise>
                    <xsl:attribute name="class">product lagervarer</xsl:attribute>
                    </xsl:otherwise>
                    </xsl:choose>
                    
                    <span class="prodImg"><img src="billeder/ask2.jpg" width="274" height="198" alt="Ask" /></span
                    <span class="ribbon">Lagervarer</span>         
                    <span class="caption">
                      <p>Ask #2</p>
                    <class="info">Mere info</p>
                    </span>
                </a>
     
    </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>

    It finds the node perfect, but my choose is wrong - what do i do wrong? :)

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Feb 09, 2011 @ 15:46
    Tom Fulton
    1

    Hi Daniel,

    There is no more @nodeTypeAlias as of 4.5

    Try:

    <xsl:when test="local-name() = 'Produkt'">

    More info:  http://our.umbraco.org/wiki/reference/xslt/45-xml-schema/no-more-@nodetypealias

    -Tom

  • Daniel Horn 319 posts 344 karma points
    Feb 09, 2011 @ 16:05
    Daniel Horn
    0

    Thanks Tom - were trying with name but didn't work. :-)

     

Please Sign in or register to post replies

Write your reply to:

Draft