RE: [xsl] Using msxsl:script or EXSLT function to define a function

Subject: RE: [xsl] Using msxsl:script or EXSLT function to define a function
From: Claudio Russo <claudio_russo@xxxxxxxxx>
Date: Wed, 18 Jun 2003 05:29:08 -0700 (PDT)
Jason,

Thanks for your help. I was able to run it with the
changes that follow. See that I do not use the CDATA
feature, and also I don't use the "user" issue.
Instead I use a "js" definition on top. The code
follows...

======================================================
<XML ID="XSLHeader">
  <xsl:stylesheet version="1.0"  
   	xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
   	xmlns:js="javascript:code"
   	xmlns:msxsl="urn:schemas-microsoft-com:xslt"
	xmlns:ms="urn:schemas-microsoft-com:xslt"
	xmlns:fo="http://www.w3.org/1999/XSL/Format";>

	<msxsl:script language="javascript"
implements-prefix="js">
	   function factorial(n)
	   {
			if (n == '1')
				{ return ( 1 ) }
			else 
				{ return ( n * factorial(n - 1) ) }
    	}
	</msxsl:script>

   		<xsl:param name="sexo"/>
   		<xsl:param name="categ"/>
   		<xsl:param name="anio"/>
   		
		<xsl:template match="portfolio">
		
    		<head>
      		</head>
        	<table border="2" width="100%" height="6">
          		<tr>
            		<td class="bg">
              		<H1><xsl:value-of
select="description"/> del <xsl:value-of
select="$anio"/> - <xsl:value-of select="$categ"/>
Años, 
                 			<xsl:choose>
      							<xsl:when
test="$sexo='V'">Varones</xsl:when>
								<xsl:otherwise>Damas</xsl:otherwise>
							</xsl:choose>
							
   						</H1>
              		<H3>Actualizado el
<xsl:apply-templates select="date"/>
						</H3>
				 		<H3>Factorial <xsl:value-of
select="js:factorial(6)"/>
						</H3>
						<P>Presione sobre los encabezados para ordenar
por dicho campo.</P>
            		</td>
          		</tr>
       	</table>
  		</xsl:template>
  
		<xsl:template match="date">
    		<xsl:value-of select="ms:format-date(., 'd',
SP_ar)"/> de <xsl:value-of select="ms:format-date(.,
'MMMMM, yyyy', SP_ar)"/>
			a las <xsl:value-of select="ms:format-time(.,
'hh:mm tt')"/>
		</xsl:template>

	</xsl:stylesheet>
</XML>


======================================================

I still don't get what this "user" def is it for. Any
place to read about it, and what should I have in it?

Also, thanks to Krishnakishore for his reply too.

--- Jason <estudio@xxxxxxxxx> wrote:
> You may try this XSLT:
> 
> <xsl:stylesheet version="1.0"
> xmlns:fo="http://www.w3.org/1999/XSL/Format";
> xmlns:msxml="urn:schemas-microsoft-com:xslt"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> xmlns:user="http://estudio.xrs.net";>
> 	<msxml:script language="JavaScript"
> implements-prefix="user"><![CDATA[ 
> 	function checking(){
> 		return "testing";
> 	}
> 	]]></msxml:script>
> 	<xsl:template match="/">
> 		<xsl:value-of select="user:checking()"/>
> 	</xsl:template>
> </xsl:stylesheet>
> 
> this is a simple example, you also can using
> parameters in the
> user-defined functions.
> 
> Jason
> 
> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On
> Behalf Of Claudio
> Russo
> Sent: 2003¦~6¤ë18¤é 11:45
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Using msxsl:script or EXSLT function
> to define a function
> 
> Does anybody know how to use msxsl:script to define
> a
> javascript function, or EXSLT function definition?
> 
> I'm not able to use it inside xsl: without having
> error.
> 
> 
> =====
> Regards, Claudio.
> 
> IT Consultant.
> Buenos Aires, Argentina.
> e-mail: claudio_russo@xxxxxxxxx
> 
> 
> __________________________________
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!
> http://sbc.yahoo.com
> 
>  XSL-List info and archive: 
> http://www.mulberrytech.com/xsl/xsl-list
> 
> 
>  XSL-List info and archive: 
> http://www.mulberrytech.com/xsl/xsl-list
> 


=====
Regards, Claudio.

IT Consultant.
Buenos Aires, Argentina.
e-mail: claudio_russo@xxxxxxxxx


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread