[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Unexpected MSXML Javascript extension results

Subject: Unexpected MSXML Javascript extension results
From: "C. Edward Porter cep@xxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 19 Jan 2017 21:22:47 -0000
 Unexpected MSXML Javascript extension results
Hello all,

We have an XSL transformation that runs using some form of MSXML for the
actual transformation. Given that MSXML is XSL 1.0, I am trying to code around
the fact that it lacks regular expression functions by writing a JavaScript
extension function to match Greek characters and wrap them in a span to avoid
them being wrongly transformed to capital letters by smallcap treatment on the
text around it. The JavaScript function I wrote appears to work fine if I run
it locally, but when run as part of the XSL, it's not recursing properly. I
don't have much of a way to debug this, so I'm hoping perhaps someone can
either recognize why I'm getting inconsistent recursion, or perhaps suggest an
alternative approach. Code/sample text below:

JavaScript Function:
 <msxsl:script language="javascript" implements-prefix="uspc"><![CDATA[
//Recursive function to wrap greek characters in nosmallcaps span
	function wrapGreek(str){
		var regex = /(.*)([N1-O	N-N)])(.*)/g;
		var m = regex.exec(str);
		var rStr = "";
		if(m != null){
			rStr = wrapGreek(m[1]);
		} else {
			rStr = str;
		if(m != null) {
			rStr += '<span class="nosmallcaps">' + m[2] + '</span>' + m[3];
			return "" + rStr;

Text template:
<xsl:template match="text()" priority="20">
	<xsl:variable name="textout">
		<xsl:value-of select="."/>
	<xsl:value-of disable-output-escaping="yes"

Sample Content:
This head composed correctly:
<title cid="pttFA"

For this one, only the second alpha symbol was wrapped, so it did not recurse.
Copying this text to a JavaScript interpreter and running the function on it
in isolation does appear to recurse correctly.
<title cid="1IMidE" id="GUID-D279E612-1350-4709-B662-8FFEF76CD0C0">InfrN1ared
AbsoN1rption, <i cid="2KvZ79">Spectrophotometric Identification Tests,
Appendix IIIC</i></title>

Thanks in advance!

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.