views:

84

answers:

2

Hi!

I am new to XSL, and thus new to using scripts within the XSL.

I have taken example code (also using C#) and adapted it for my own use.. but it does not work.

EDIT: This code works in Visual Studio.. The error is only generated in Oxygen... I am still wanting to have it error free in Oxygen, so any insight is appreciated!

The error message is: The URI urn:cs-scripts does not identify an external Java class

The relevant code I have is:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
xmlns:tok="urn:cs-scripts">

...
...
...
</xsl:template>


<xsl:variable name="temp">
    <xsl:value-of select="tok:getList('AAA BBB CCC', ' ')"/>
</xsl:variable>

<msxsl:script language="C#" implements-prefix="tok">
    <![CDATA[
    public string[] getList(string str, char[] delim)
  {
     return str.Split(delim, StringSplitOptions.None);
  }

  public string getString(string[] list, int i)
  {
     return list[i];
  }
  ]]>
</msxsl:script>


</xsl:stylesheet>
+2  A: 

The declaration

xmlns:tok="urn:cs-script"

refers to a function created in C# within your XSLT. Oxygen is created in java, and thus cannot load/compile the C# generated callback function.

If you want to remove the error in Oxygen, then remove the C# specific callback function (which only will work in a .Net environment).

Mikael Svenson
@Svenson: hmm.. so I can't use C#. And I have to use Java? no other scripts would work? javascript? php? etc.?
developer
If you execute the XSLT in .Net, then you can use it (and just ignore the Oxygen error). If you use the xslt in some other environment, then you cannot use it. You will have to create pure XSLT functions without callback to an external runtime.
Mikael Svenson
+2  A: 

You don't need an extension function for splitting a string into words.

Just use the FXSL 1.x template str-split-to-words as described here.

Because FXSL is written in XSLT, it works with any XSLT 2.0 processors and for XSLT 1.x -- with MSXML or any processor that supports the EXSLT node-set() extension (also supported by XslCompiledTransform in .NET).

Dimitre Novatchev
I actually currently am using a recursive solution in xsl, but what I need to accomplish will be getting even more complex, and it was cleaner to add the extension function. I have some other things that I will want to do with C#, so I will have to switch to Visual Studio for these files (even though Oxygen is much nicer to use for xsl.. :S ) But thanks for your response! Always appreciate it :)
developer