If you get an error about a missing namespace then you need to add the msxsl as a namespace in the top of your XSLT file where the other namespaces are declared.
Ok - Could you try debugging the above code by commenting out sections of it? Do you see the error if you comment out everything else than the dropdownListValue variable?
If not then try removing the uncomment the bodyText variable and so on untill you know what triggers the error.
Error saving XSLT
Hi
I am receving an error when trying to save out an XSLT Contour form. The error is as follows:
Error occured
System.Xml.Xsl.XslTransformException: Expression must evaluate to a node-set.
at System.Xml.Xsl.Runtime.XsltConvert.EnsureNodeSet(IList`1 listItems)
at (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
at Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter results)
at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer)
at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, XmlWriter results, XmlResolver documentResolver)
at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results)
at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging)
The code block that has the issue seems to be this:
<xsl:variable name="dropdownlistValue" select="$records//fields/bookingtype//value"/>
<!-- Read form contents into a variable ready for sending -->
<xsl:variable name="bodyText">
<p>BOOKING REQUEST<br /><br /></p>
<xsl:for-each select="$records//fields/child::*">
<strong><xsl:value-of select="./caption" />: </strong><xsl:value-of select=".//value" /><br /><br />
</xsl:for-each>
</xsl:variable>
<xsl:choose>
<xsl:when test="$dropdownlistValue = 'Hospital Specialist'">
<xsl:value-of select="umbraco.library:SendMail('[email protected]', '[email protected]', 'NEH: Hospital Specialist Request', $bodyText, 'true')"/>
<!--<xsl:value-of select="umbraco.library:SendMail('[email protected]', '[email protected]', 'NEH: Hospital Appointment Request', $bodyText, 'true')"/>-->
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="umbraco.library:SendMail('[email protected]', '[email protected]', 'NEH: Equine Practice Request', $bodyText, 'true')"/>
</xsl:otherwise>
</xsl:choose>
Any help would be greatfully received.
Lee
Hi Lee
If I read the above code right you need to add msxsl:node-set() around the $records//fields/child::* - Like this
If you get an error about a missing namespace then you need to add the msxsl as a namespace in the top of your XSLT file where the other namespaces are declared.
Hope this helps.
/Jan
Thanks Jan... Appreciate your reply. I am still getting the same error. Here is the complete code:
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:user="urn:my-scripts" xmlns:umbraco.library="urn:umbraco.library" exclude-result-prefixes="xsl msxsl user umbraco.library">
<xsl:output method="html" media-type="text/html" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="DTD/xhtml1-strict.dtd" cdata-section-elements="script style" indent="yes" encoding="utf-8" />
<xsl:param name="records" />
<xsl:template match="/">
<!-- start writing XSLT-->
<!--Read Dropdown List Value into variable -->
<xsl:variable name="dropdownlistValue" select="$records//fields/bookingtype//value"/>
<!-- Read form contents into a variable ready for sending -->
<xsl:variable name="bodyText">
<p>BOOKING REQUEST<br /><br /></p>
<xsl:for-each select="msxsl:node-set($records//fields/child::*)">
<strong><xsl:value-of select="./caption" />: </strong><xsl:value-of select=".//value" /><br /><br />
</xsl:for-each>
</xsl:variable>
<xsl:choose>
<xsl:when test="$dropdownlistValue = 'Hospital Specialist'">
<xsl:value-of select="umbraco.library:SendMail('[email protected]', '[email protected]', 'NEH: Hospital Specialist Request', $bodyText, 'true')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="umbraco.library:SendMail('[email protected]', '[email protected]', 'NEH: Equine Practice Request', $bodyText, 'true')"/>
</xsl:otherwise>
</xsl:choose>
<!-- A reminder for yourself -->
<p>Contour form submitted!</p>
</xsl:template>
</xsl:stylesheet>
Hi Lee
Ok - Could you try debugging the above code by commenting out sections of it? Do you see the error if you comment out everything else than the dropdownListValue variable?
If not then try removing the uncomment the bodyText variable and so on untill you know what triggers the error.
Looking forward to hearing from you.
/Jan
Seems to be:
<xsl:variable name="dropdownlistValue" select="$records//fields/bookingtype//value"/>
and then
<xsl:when test="$dropdownlistValue = 'Hospital Specialist'">
Hi Lee
Ok, then you should wrap the content in the dropdownlist variable in the msxsl:node-set(). So try wrapping it like this
Does that work?
/Jan
is working on a reply...