JScript XSL problems

N

nilun75

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?
 
P

pr

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

Code

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 said:
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.
 
N

nilun75

Hmm...
Why does this not work when I process it. Could be my xsl processor,
anyone have an idea of a good xsl processor?
 
M

Martin Honnen

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?
 
N

nilun75

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
 
D

Dr J R Stockton

In comp.lang.javascript message <aa5d0133-cf31-4617-8f39-e038502e0926@q3
3g2000hsh.googlegroups.com>, Wed, 27 Feb 2008 01:41:54,
(e-mail address removed) 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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,145
Messages
2,570,825
Members
47,371
Latest member
Brkaa

Latest Threads

Top