Copied to clipboard

Flag this post as spam?

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


  • Lee 95 posts 115 karma points
    Dec 03, 2014 @ 15:06
    Lee
    0

    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&lt;br /&gt;&lt;br /&gt;</p>

                <xsl:for-each select="$records//fields/child::*">

                    <strong><xsl:value-of select="./caption" />: </strong><xsl:value-of select=".//value" />&lt;br /&gt;&lt;br /&gt;

                </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

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Dec 03, 2014 @ 15:52
    Jan Skovgaard
    0

    Hi Lee

    If I read the above code right you need to add msxsl:node-set() around the $records//fields/child::* - Like this

    <xsl:for-each select="msxsl:node-set($records//fields/child::*)">
    

    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

  • Lee 95 posts 115 karma points
    Dec 03, 2014 @ 16:37
    Lee
    0

    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&lt;br /&gt;&lt;br /&gt;</p>

    <xsl:for-each select="msxsl:node-set($records//fields/child::*)">

                    <strong><xsl:value-of select="./caption" />: </strong><xsl:value-of select=".//value" />&lt;br /&gt;&lt;br /&gt;

                </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>

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Dec 03, 2014 @ 19:28
    Jan Skovgaard
    0

    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

  • Lee 95 posts 115 karma points
    Dec 03, 2014 @ 23:11
    Lee
    0

    Seems to be:

    <xsl:variable name="dropdownlistValue" select="$records//fields/bookingtype//value"/>

    and then

     <xsl:when test="$dropdownlistValue = 'Hospital Specialist'">

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Dec 04, 2014 @ 05:46
    Jan Skovgaard
    0

    Hi Lee

    Ok, then you should wrap the content in the dropdownlist variable in the msxsl:node-set(). So try wrapping it like this

    <xsl:variable name="dropdownlistValue" select="msxsl:node-set($records//fields/bookingtype//value)" />
    

    Does that work?

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft