This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
regarding the extension library
- From: "william locksman" <vsd18 at rediffmail dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: 14 May 2002 11:13:42 -0000
- Subject: [xsl] regarding the extension library
- Reply-to: xsl-list at lists dot mulberrytech dot com
hello i have a question regarding using the extension library
function ussage.
i have seen articles that use the toUpperCase of String method in
the following way.
for xml
<colors>
<color>red</color>
<color>blue</color>
<color>green and pink</color>
</colors>
using the java's to upper case, the xsl would be
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xalan = "http://xml.apache.org/xalan"
exclude-result-prefixes="xalan" xmlns:java = "java">
<xsl:template match="/">
<xsl:for-each select="/colors/color">
<xsl:variable name="color" select="java:lang.String.new(.)"/>
from java: <xsl:value-of select="java:toUpperCase($color)"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
where we instantiate the String object by saying
java:lang.String.new() and then call the toUpperCase Method on
that string. thaz fine.
I have then formed my own utility class that returns the string in
the uppercase( just for test purpose ). This Class is StrUtils
which has a method called upperCase()that takes the String to be
converted to the uppercase and returns String in uppercase.
( I am doing this purely for test purpose)
and i am calling this method in the following way in my XSL
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xalan = "http://xml.apache.org/xalan"
exclude-result-prefixes="xalan"
xmlns:str-utils = "com.xyz.StrUtils" extension-element-prefixes
="str-utils" >
<xsl:template match="/">
<xsl:for-each select="/colors/color">
<xsl:variable name="color" select="."/>
<xsl:value-of select="str-utils:upperCase($color)"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
This works fine too. My question is that in my Example, where is
the instantiation being done?? I have not done anything like
com.xyz.StrUtils.new()... so how is it working??
what is the theory behind the object instantiation when it comes
to extension libraries??
i would be thankful if someone can please tell me about this.
_________________________________________________________
Click below to visit monsterindia.com and review jobs in India or
Abroad
http://monsterindia.rediff.com/jobs
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list