Groups | Blog | Home
all groups > dotnet xml > november 2003 >

dotnet xml : Regular Expression in XSLT failing


walterware NO[at]SPAM aol.com
11/12/2003 2:31:16 PM
Hello....

An XSLT file that I am using function correctly when called from a
browser but fails when used within .NET Transform function.

The code follows:
<msxsl:script language="JScript" implements-prefix="wg"><![CDATA[
/*-----------------------------------------------
FUNCTION: GetFiscalYear 1.0 / 20030313
PURPOSE:
-----------------------------------------------*/
function GetFiscalYear(vDate) {
/*
original
var rDATE = /^([0-9]{4})\-([0-9]{2})\-([0-9]{2})(([0-9]{2}):([0-9]{2}):([0-9]{2}))?$/;
replacement */
var rDATE = /^.*?$/;
var sDate, aDate, dDate;
var nFY = 0;
if(typeof(vDate) == "object") sDate = NodeValue(vDate); // convert
nodeset to string
if(typeof(sDate) != "string") return 0; // handle bad parameter
variant type
aDate = rDATE.exec(sDate); // check for expected date format
if(aDate == null) return -2;
dDate = new Date(eval(aDate[1]), eval(aDate[2]) - 1, eval(aDate[3]));
dDate.setMonth(dDate.getMonth() + 6);
nFY = dDate.getFullYear();
return nFY;
}

If I use the original rDATE, this function alway returns a -2. The
replacement doesn't cause a faile but also does not help me find a
problem.

Any clues ???

Thank you,
walterware NO[at]SPAM aol.com
11/13/2003 12:07:26 PM
Thank you for your quick response.

In case of the AddParams query that you also reponded to, I was able
to do the research and formulate the correct syntax to get my results.

In this one, however, I am up a tree. If I use the generalize regular
expression, the function does seem to work. So I think it is either
the syntax of the regular expression or its use by the exec method.
But I cannot discern which.

Does anything obvious stare out at you ??

Regards,
Charly

[quoted text, click to view]
Oleg Tkachenko
11/13/2003 1:56:57 PM
[quoted text, click to view]

Make sure you function is valid JScript.NET function.
--
Oleg Tkachenko
XML Insider
http://www.tkachenko.com/blog
AddThis Social Bookmark Button