I am received the following error while trying to implement a C# extension function in XSLT.
Extension function parameters or return values which have CLR type ‘Char[]’ are not supported.**
code:
<xsl:variable name="stringList">
<xsl:value-of select="extension:GetList('AAA BBB CCC', ' ')"/>
</xsl:variable>
<msxsl:script language="C#" implements-prefix="extension">
<![CDATA[
public string[] GetList(string str, char[] delimiter)
{
...
...
return str.Split(delimiter, StringSplitOptions.None);
}
]]>
</msxsl:script>
Can someone explain this error message and how to get past it?
EDIT: I need a solution that still lets me implement the split function and make use of the array returned.
Thanks!
XSLT extension methods must return a type that is supported within XSL transformations. The following table shows the W3C XPath types and their corresponging .NET type:
The table is taken from the section Mapping Types between XSLT and .NET in this MSDN Magazine article.
Instead of returning a
string[]array you would have to return anXPathNodeIteratorlike it is done in the following example:In your XSL transform you can then iterate over the elements in the returned node set using
xsl:for-each: