Subject:Problems using JScript with the built in parser Author:Scot Greenidge Date:22 Jun 2005 10:06 PM
Hello,
I am having problems using the attached embedded JScript function within my XSLT transform. When using either the external MSXML or MSXML 4.0 parsers from within StylusStudio, the script executes without error. When attempting to use either the StylusStudio built in parser or the MSXML .NET parser, I get the following errors:
Any ideas on why MSXML and MSXML 4.0 consider the script correct and why the built-in parser and/or MSXML .NET fail? I have been unable to determine the root cause.
Here's the embedded JScript function:
<ms:script language="JScript" implements-prefix="usr">
<![CDATA[
function parseSubType(inType) {
var outSubType;
if (typeof(inType) == "object") {
var nodeValue = inType.item(0).childNodes[0].nodeValue;
var tempSubType = new String(nodeValue);
var index = tempSubType.lastIndexOf(".");
outSubType = tempSubType.slice(index+1);
} else {
outSubType="FAILURE-UNSUPPORTED-JSCRIPT-TYPE";
}
return outSubType;
}
]]>
</ms:script>
Subject:Problems using JScript with the built in parser Author:Ivan Pedruzzi Date:23 Jun 2005 09:47 PM
Hi Scot,
I am able to run your script the built-in processor.
With .NET what you are seeing is a runtime error because most likely the script is trying to navigate a DOM node that doesn’t exist.
Are you sure you need a script extension?
Tell us what you are trying to do may be can done with just XSLT.
Subject:Problems using JScript with the built in parser Author:Scot Greenidge Date:24 Jun 2005 11:46 AM
Thank you for the reply Ivan.
I am pretty sure that I am navigating to a valid DOM node but will check this. As I said in my original post both the external MSXML and MSXML 4.0 parsers don't exhibit the same problem given the same data set and XSLT code.
With regard to the question of whether or not the use of an external script is required, I am trying to parse the content of an attribute node that looks something like:
I am fairly new to XSLT so there may well be a much better approach to the problem. The use of JScript seemed like the most direct path to gain the additional string parsing capability. I would welcome an alternate approach that just uses XSLT/XPath techniques.
Subject:Problems using JScript with the built in parser Author:Scot Greenidge Date:27 Jun 2005 12:42 PM
Thank you very much for the tutorial Ivan, I appreciate it. Yes, the solution works as you describe. Thank you as well for the pre-notice on the additional support for tokenize in XSLT 2.0.