samedi 27 juin 2015

MSXML XSLT Transformation - Passed in node from XPath has no value

All,

I am using .net 4.0, and the old deprecated XslTransform() class to perform a transformation of an xml order to an html output. I have an javascript function that is passed in a node w/ the following xpath expression:

<xsl:value-of select="user:renderNode(//items/item/Comments[string-length(text()) > 0])" disable-output-escaping="yes"/>

I have verified using an xpath tool that the XPath expression returns me a node which contains text content. Unfortunately, in the javascript function itself, when I say

return node.nodeValue;

or

return node.text;

the value "node" contains no text.

Here's the entire example:

var t = new XslTransform();
        t.Load("res/OrderConfirmationTemplateRX.xsl");
        t.Transform("res/order.xml", "res/output.htm");


        string output;
        using (var reader = File.OpenText("res/output.htm"))
        {
            output = reader.ReadToEnd();
        }

And XSLT:

    <msxsl:script language="JScript" implements-prefix="user">
    <![CDATA[
        function renderNode(node) {
            return node.nodeValue;

        }


    ]]>
</msxsl:script>

    <tr>
                    <td colspan="6">
                        <xsl:value-of select="user:renderNode(//items/item/Comments[string-length(text()) > 0])" disable-output-escaping="yes"/>
                    </td>
                </tr>

Aucun commentaire:

Enregistrer un commentaire