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 26, 2011 @ 17:35
    Daniel Horn
    0

    Unordered lists XSLT wont work

    I'm using the multiple textstring datatype from ucomponents to create two lists.

    I'm trying to output it with this XSLT but it doesnt work.. any ideas why?

    <?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:template match="fordele | ulemper">
      <ul>
       <xsl:apply-templates/>
      </ul>
     </xsl:template>
     <xsl:template match="fordele">
      <li><xsl:value-of select="."/></li>
     </xsl:template>
        
    </xsl:stylesheet>

  • Daniel Horn 319 posts 344 karma points
    Feb 26, 2011 @ 17:42
    Daniel Horn
    0

    Here is the XML:

    <root id="-1"><Forside><Tekstside id="1081" level="3" nodeName="Test" urlName="test">
       
    <umbracoRedirect />
       
    <overskrift>Test</overskrift>
       
    <tekst></tekst>
       
    <sidensTitel />
       
    <sidensBeskrivelse />
       
    <sidensNgleord />
       
    <Faktaboks id="1113" level="4" nodeName="Det her virker" urlName="det-her-virker">
           
    <umbracoNaviHide>1</umbracoNaviHide>  -
           
    <fordele>
               
    <values>
                   
    <value>Ingen emission</value>
                   
    <value>Det virker bare</value>
                   
    <value>Det er top nice</value>
                   
    <value>Det er bare fedt</value>
                   
    <value>Udstødnings</value>
                   
    <value />
               
    </values>
           
    </fordele>
           
    <ulemper>
               
    <values>
                   
    <value>Giver sygdom</value>
                   
    <value>Er farligt</value>
                   
    <value />
               
    </values>
           
    </ulemper>
       
    </Faktaboks>
    </Tekstside></Forside></root>

  • Daniel Horn 319 posts 344 karma points
    Feb 26, 2011 @ 19:26
    Daniel Horn
    0

    This works for outputting the "fordele", but would be nice to be able to output both in same xslt file - and still have them seperated as two lists

    <?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:template match="/">
          <ul>
            <xsl:apply-templates select="$currentPage/Faktaboks/fordele" />
          </ul>
          </xsl:template>
          
        <xsl:template match="value">
          <li><xsl:value-of select="."/></li>
        </xsl:template>
        
    </xsl:stylesheet>

  • Daniel Horn 319 posts 344 karma points
    Feb 26, 2011 @ 19:31
    Daniel Horn
    0

    Got a little further, but got a tiny issue still - it seems to be outputting the "1" from the element when using this XSLT:

    Another problem is that I cant give the UL different classes - so I guess I have to create two XSLT files for this job? :)

     

    version="1.0" encoding="UTF-8"?>
    DOCTYPE xsl:stylesheet [
      ENTITY nbsp " ">
    ]>
    <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:template match="/">
            <xsl:apply-templates select="$currentPage/Faktaboks" />
          xsl:template>
        
        <xsl:template match="fordele|ulemper">
      <ul>
       <xsl:apply-templates/>
      ul>
     xsl:template>
          
        <xsl:template match="value">
          <li><xsl:value-of select="."/>li>
        xsl:template>
        
    xsl:stylesheet>

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Feb 26, 2011 @ 19:40
    Jan Skovgaard
    0

    Hi Daniel

    What do you mean by the "1"?

    I'm not sure...but woul'nt you somehow be able to set different class names like this...

    <ul>
    <xsl:if test="name(.) = 'fordele'">
    <xsl:attribute name="class">fordele</xsl:attribute>
    </xsl:if>

    <xsl:if test="name(.) = 'ulemper'">
    <xsl:attribute name="class">ulemper</xsl:attribute>
    </xsl:if>

    <!-- your apply template here -->

    </ul>

    Does this work?

    /Jan

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    Feb 26, 2011 @ 20:26
    Chriztian Steinmeier
    2

    Hi Daniel,

    These templates will work - you definitely won't need two files for that; and for the separate classes - well :-)

    <xsl:template match="/">
        <xsl:apply-templates select="$currentPage/Faktaboks" />
    </xsl:template>
    
    <xsl:template match="Faktaboks">
        <xsl:apply-templates select="fordele | ulemper" />
    </xsl:template>
    
    <xsl:template match="fordele | ulemper">
        <ul class="{name()}">
            <xsl:apply-templates/>
        </ul>
    </xsl:template>
    
    <xsl:template match="value">
        <li>
            <xsl:value-of select="."/>
        </li>
    </xsl:template>
    

    /Chriztian

  • Daniel Horn 319 posts 344 karma points
    Feb 26, 2011 @ 21:06
    Daniel Horn
    0

    Thanks guys - Chriztian that worked totally as i wanted it :-)

Please Sign in or register to post replies

Write your reply to:

Draft