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.
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:
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
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:
(Note the single-quotes inside the variable's select - they're important!)
/Chriztian
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"/>
Ahh, my mistake. I've mistyped the fieldname.
I got it working.
Thanks for your help.
Palle
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:
/Chriztian
Great - all well, then :)
is working on a reply...