1

Slowly going mad over this and have tried various solutions found here but nothing seems to be working so far.

I have some XSL as such:

<xsl:variable name="reserved">
    <xsl:value-of select="utils:getReservedCodes()"/>
</xsl:variable>

The value of which is determined by some JScript:

function getReservedCodes() {
    reservedCodes = reservedCodesList.join("");
    return reservedCodes;
}   

If I output the value of reserved using

<xsl:value-of select="$reserved"/> 

I get something like this:

<codey value="-STB"></codey><codey value="-SO"></codey>

I'm then attempting to use the contents of this variable as a node set:

<xsl:for-each select="msxsl:node-set($reserved)/codey">
    <xsl:value-of select="@value"/>
</xsl:for-each>

This for-each loop doesn't output anything. I get the impression from other answers here that this could be a namespace issue so I've tried declaring the variable with xmlns="", I've surrounded all the codey entries with <Codes xmlns=""> and I've also tried using the JScript prefix in case it was that but I can't seem to get anything to work.

I have no default namespace in my stylesheet:

<?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:utils="urn:utils">

and in case it's of any use, my script header looks like this:

<msxsl:script implements-prefix="utils" language="javascript">

If anyone out there has any suggestions I would be eternally grateful.

  • I don't see how `` could create any element nodes (like the `codey` elements) at all as `xsl:value-of` simply creates a text node. So consider to provide minimal but complete sample to allow us to understand and reproduce the problem. What is the JScript function returning, a plain JScript string? Which XSLT processor do you use exactly, the `msxsl` namespace you use is support by the various MSXML versions but as well by the .NET implementations XslCompiledTransform and XslTransform and some third party competitors like XmlPrime. – Martin Honnen Jul 24 '18 at 16:20

1 Answers1

0

Just in case it helps anyone else landing here, I managed to get around my issue by applying the code from this question and having my JScript return a comma-delimited string.