Copied to clipboard

Flag this post as spam?

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


  • Morten Balle 38 posts 129 karma points
    Nov 22, 2011 @ 09:32
    Morten Balle
    0

    Contour Poll - FormID

    Today I’m struggeling a bit with your tutorial to make a contour poll.

    (With great help from Tim: http://www.nibble.be/?p=81)

    My xslt will not render when adding the form-id,

    What I’m using is the form GUID grabbed from contour form settings tab.
    Like this:
    4e964597-4c5a-4457-a4cc-69fa210e2a69

    Adding this ID directly in the xslt it gives this error:
    System.Xml.Xsl.XslLoadException: Scientific notation is not allowed. ....

     How do I find or set the form-id to make it work correct..?

    Best,
    Morten


  • Profiterole 232 posts 264 karma points
    Nov 22, 2011 @ 13:57
    Profiterole
    0

    Hi, normaly, you should use something like this :

      <xsl:variable name="records" select="umbraco.contour:GetRecordsFromForm('4e964597-4c5a-4457-a4cc-69fa210e2a69')"/>

    And then get results from $records. Your ID is correct.

  • Morten Balle 38 posts 129 karma points
    Nov 22, 2011 @ 14:17
    Morten Balle
    0

    Thanks.

     

    However I can't make it work in a variable. Still get the error:
    System.Xml.Xsl.XslLoadException: Scientific notation is not allowed. ....

    Would you be able to post a full xslt-copy for me to compare with..?

     

    Best,

    MOrten

  • Profiterole 232 posts 264 karma points
    Nov 22, 2011 @ 22:55
    Profiterole
    0

    Here's my code :

    To get the formid, I use a formpicker in the macro.

    <?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:contourpoll="urn:contourpoll" xmlns:umbraco.contour="urn:umbraco.contour"
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets umbraco.contour contourpoll">


    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>

        <xsl:param name="formid" select="/macro//formid" />
        
    <xsl:template match="/">
      
        <xsl:if test="$formid">
         <xsl:variable name="records" select="umbraco.contour:GetRecordsFromForm($formid)"/>
         <xsl:variable name="numberOfRecords" select="count($records/uformrecord)" />


        
        
       <div class="results" style="width:200px; margin-left:0px;">
           <h2>Résultats du sondage</h2>
         
         <xsl:for-each select="contourpoll:PossibleAnswers($formid)//question">
        <xsl:variable name="numberOfAnswers" select="count(./answer)" />
           
        <xsl:value-of select="caption"/>
          <ul style="list-style:none;padding-left:0px;margin-left:20px;">
            <xsl:for-each select=".//answer">
          <xsl:sort select="count($records//value [@key = current()/@id])" data-type="number" order="descending"/>

          <xsl:variable name="currentId" select="@id" />
          <xsl:variable name="currentVotes" select="count($records//value [@key = $currentId])" />
          <xsl:variable name="currentPercentage" select="round (($currentVotes div $numberOfRecords) * 100)"/>
          
          <li>
              <xsl:value-of select="."/>
              <div class="scorebarcontainer" style="width:100%;background-color:#eee;height:20px"><span style="float:left;"><xsl:value-of select="$currentPercentage"/> %</span>
                <div class="scorebar" style="width:{$currentPercentage}%;background-color:#ccc;height:20px"></div>
            
            </div>
                  </li>
       </xsl:for-each>
      </ul>
           </xsl:for-each>
        </div>

      
        </xsl:if>
    </xsl:template>

    </xsl:stylesheet>
  • Morten Balle 38 posts 129 karma points
    Nov 22, 2011 @ 23:24
    Morten Balle
    0

    You're my man!

    Was the xslt extension that was'nt registered correct.

     

    Thanks!

Please Sign in or register to post replies

Write your reply to:

Draft