Copied to clipboard

Flag this post as spam?

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


  • Palle Hansen 143 posts 396 karma points
    May 21, 2014 @ 22:00
    Palle Hansen
    0

    Contour problem getting data

    Hi,

    I need to make a for-each loop using this in my XSLT, getting data from #Form_name
    <xsl:for-each select="umbraco.contour:GetApprovedRecordsFromPage(1145)//#Form_name/values/value">
    But I get this error when I try to save: Unexpected token '#' in the expression. 
    I've tried with this <![CDATA[ ]]> but with no luck.

    If I try getting data from this - 'email' I get all the data, so all other code seems to be working.

     

    I can't remove the # because it seems that I don't get previous data then.

    Can anyone help me get around it?

     

    Best regards 
    Palle






     

     

     

     

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    May 21, 2014 @ 22:08
    Chriztian Steinmeier
    0

    Hi Palle,

    You can't use the hash character like that in an XPath expression - are you trying to get to a specific field? Do you have the fieldname in some variable? (Are you trying to get it from the Dictionary/Cookies/Query?)

    If you have the fieldname somewhere, you can use a predicate, like this:

    <xsl:variable name="fieldName" select="'EmailOptions'" />
    <xsl:for-each select="umbraco.contour:GetApprovedRecordsFromPage(1145)//*[name() = $fieldName]/values/value">
    

    (Note the single-quotes inside the variable's select - they're important!)

    /Chriztian

  • Palle Hansen 143 posts 396 karma points
    May 21, 2014 @ 22:26
    Palle Hansen
    0

    Hi Chriztian.

    I'm trying to get it from a field in Contour.

    Now I have this but it returns no data.
    Can you see why?

    <xsl:variable name="fieldName" select="'#Form_name'"/>    

        <xsl:variable name="names">      
         <xsl:for-each select="umbraco.contour:GetApprovedRecordsFromPage(1145)//*[name() = $fieldName]/values/value">          
            <xsl:choose>
              <xsl:when test="position() != last()">
                <xsl:text disable-output-escaping="yes">"</xsl:text><xsl:value-of select="."/><xsl:text disable-output-escaping="yes">", </xsl:text>
              </xsl:when>
              <xsl:otherwise>
                <xsl:text disable-output-escaping="yes">"</xsl:text><xsl:value-of select="."/><xsl:text disable-output-escaping="yes">"</xsl:text>
              </xsl:otherwise>
            </xsl:choose>        
          </xsl:for-each>        
        </xsl:variable>
      
      <xsl:copy-of select="$names"/> 

  • Palle Hansen 143 posts 396 karma points
    May 21, 2014 @ 22:39
    Palle Hansen
    100

    Ahh, my mistake. I've mistyped the fieldname.
    I got it working.

    Thanks for your help.

    Palle 

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    May 21, 2014 @ 22:47
    Chriztian Steinmeier
    0

    Hi Palle,

    You need to check that #Form_name thing - that can't be the name used in the XML from Contour...

    Where do you get #Form_name from? Is it the name of the form, or a field on the form?

    BTW: Here's a much shorter XSLT snippet that does the same:

    <xsl:variable name="fieldName" select="'#Form_name'" />
    <xsl:variable name="quote">"</xsl:variable>
    
    <xsl:variable name="names">      
        <xsl:for-each select="umbraco.contour:GetApprovedRecordsFromPage(1145)//*[name() = $fieldName]/values/value">
            <xsl:value-of select="concat($quote, ., $quote)" />
            <xsl:if test="not(position() = last())">, </xsl:if>
        </xsl:for-each>
    </xsl:variable>
    

    /Chriztian

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    May 21, 2014 @ 22:47
    Chriztian Steinmeier
    0

    Great - all well, then :)

  • 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