473,385 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

JScript XSL problems

Hi, I have a problem with a probably simple xsl that uses javascript.
Hope anyone can help me with this one.

Code
--------
<xsl:stylesheet version="1.1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:js="http://www.oracle.com/XSL/Transform/java/java.lang.String"
xmlns:msxml="urn:schemas-microsoft-com:xslt">

<msxml:script language="JScript" implements-prefix="js">
function retTime() {
var currentTime = new Date();
var month = currentTime.getMonth()+1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();

var hour = currentTime.getHours();
var mins = currentTime.getMinutes();
var secs = currentTime.getSeconds();

return(year + "" + month + "" + day + "" + hour + "" + mins + "" +
secs)
}
</msxml:script>

<xsl:template match="/">
<DATETIME>
<xsl:value-of select="js:retTime()"/>
<xsl:text>***SOME_TEXT***</xsl:text>
</DATETIME>
</xsl:template>

</xsl:stylesheet>

---

Error message I get is:
<Line 23, Column 40>: XML-22043: (Error) Extension function error:
Method not found 'retTime'

Can anyone help me with this one?
Feb 27 '08 #1
5 2347
pr
ni*****@gmail.com wrote:
Hi, I have a problem with a probably simple xsl that uses javascript.
Hope anyone can help me with this one.

Code
--------
<xsl:stylesheet version="1.1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:js="http://www.oracle.com/XSL/Transform/java/java.lang.String"
That's a funny namespace name to choose for a JScript extension
function, but it isn't your problem.
xmlns:msxml="urn:schemas-microsoft-com:xslt">

<msxml:script language="JScript" implements-prefix="js">
function retTime() {
var currentTime = new Date();
var month = currentTime.getMonth()+1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();

var hour = currentTime.getHours();
var mins = currentTime.getMinutes();
var secs = currentTime.getSeconds();

return(year + "" + month + "" + day + "" + hour + "" + mins + "" +
secs)
You only need one "" (eg. "" + year + month ...) to force string
concatenation, but that isn't your problem.
}
</msxml:script>

<xsl:template match="/">
<DATETIME>
<xsl:value-of select="js:retTime()"/>
<xsl:text>***SOME_TEXT***</xsl:text>
</DATETIME>
</xsl:template>

</xsl:stylesheet>

---

Error message I get is:
<Line 23, Column 40>: XML-22043: (Error) Extension function error:
Method not found 'retTime'
I get the result

200822711420***SOME_TEXT***

using the stylesheet in an <?xml-stylesheet ...?processing instruction.
Can anyone help me with this one?
Since the script doesn't appear to be at fault, you would be better off
asking in microsoft.public.xsl or one of the MS forums.
Feb 27 '08 #2
Hmm...
Why does this not work when I process it. Could be my xsl processor,
anyone have an idea of a good xsl processor?
Feb 27 '08 #3
ni*****@gmail.com wrote:
Hmm...
Why does this not work when I process it. Could be my xsl processor,
anyone have an idea of a good xsl processor?

Extension functions and elements are not portable, the msxsl:script
element works with Microsoft's MSXML processor and with Microsoft's
XslTransform and XslCompiledTransform in .NET although supporting
different languages.

Which XSLT processor are you using?
--

Martin Honnen
http://JavaScript.FAQTs.com/
Feb 27 '08 #4
Hi Martin

This processor was created by some developers in our company and I
think that you might be right.
I am relatively new to xsl so I don't know what processor to use.

Thanks for your help.

/Nicklas

Feb 27 '08 #5
In comp.lang.javascript message <aa5d0133-cf31-4617-8f39-e038502e0926@q3
3g2000hsh.googlegroups.com>, Wed, 27 Feb 2008 01:41:54,
ni*****@gmail.com posted:
>
return(year + "" + month + "" + day + "" + hour + "" + mins + "" +
secs)
With that format, 2008111223344 has two interpretations; and it is by no
means unique. Consider 20081111111, which is worse. Read ISO 8601.

--
(c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05.
Web <URL:http://www.merlyn.demon.co.uk/- w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/- see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Feb 28 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

29
by: Christopher Brandsdal | last post by:
If I have a .ASP page that runs JScript code - is it possible to include an ..ASP page that runs VBscript???
20
by: Harag | last post by:
Hi All. I'm stating out doing some web developing. I was wondering which of the server side languages should I concentrate on and learn. I Know CSS, HTML, T-SQL I can look at the client...
4
by: Harag | last post by:
Hi All I currently thinking of converting from my little knowledge of VBscript to jScript ASP. With this in mind I'm looking at my current code to see how it will convert over to Jscript. ...
6
by: Berislav Lopac | last post by:
One of the banes of contemporary JavaScript programming for the Web is the differences between JScript and JavaScript -- specifically, a number of non-standard, but useful objects and/or methods...
14
by: John Bentley | last post by:
Note this is crossposted to comp.lang.javacript and microsoft.public.dotnet.scripting. After some Googling and FAQing my understanding of these terms is, crudely: Javascript (3 different...
1
by: David Laub | last post by:
I have no problems running the following dynamic XPath evaluator form MSXSL: <msxsl:script implements-prefix="dyn" language="jscript"> evaluate(context, expression) { return...
6
by: RFS666 | last post by:
Hello, After I posted yesterday "using C# class in jscript", I have a new problem: I have a C# class - DBResult - that contains (and other variables) a string array (and other variables), that...
7
by: VK | last post by:
Something *big* is cooking: the entire Microsoft JScript section is down: <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/js56jslrfjscriptlanguagereference.asp> ...
3
by: bowser | last post by:
Hello, I have a problem of communication between JScript and C#. I must say that I'm new to both. In a JS file I have to call a C# function. In particular I have: public function Eval(expr :...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.