This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: reposting.extension library question


Well I have a shot at this...

Regarding instantiation, the following line handles this:
xmlns:str-utils = "com.xyz.StrUtils" extension-element-prefixes ="str-utils"

Your telling Xalan to set str-utils as the class com.xyz.StrUtils which is a
call to its no-args constructor.  Tinker with various constructors and you
should find that you can weave in fairly complex java objects. Note that
while I'm not familiar with many other programming languages, I don't think
Xalan cares what language com.xyz.StrUtils is written in so long as the
system or env recognizes it.

Regarding you class, since everything is public, so long as your system or
server is aware of the class via a classpath, Xalan should have no trouble
making calls to its methods.

On a side note, are you running this test from command line or from within
an IDE?  Basically this will simply tell us what mechanism is setting your
classpath.

I am a relative newbie so please don't skewer my assumptions.

Thanks and good luck.


-->  -----Original Message-----
-->  From: william locksman [mailto:vsd18@rediffmail.com]
-->  Sent: Wednesday, May 15, 2002 9:53 AM
-->  To: xsl-list@lists.mulberrytech.com
-->  Subject: [xsl] reposting.extension library question
-->  
-->  
-->  hello , sorry to repost this question..
-->  i did not get a response for my question. can some one please 
-->  answer me??
-->  
-->  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??
-->  
-->  The StrUtils Class is as follows
-->  
-->  public class StrUtils {
-->  
-->       /**
-->        *  Constructor for the StringUtils object
-->        */
-->       public StringUtils() { }
-->  
-->       public String upperCase(String str) {
-->           return "str.toUpperCase() "+str.toUpperCase();
-->       }
-->  }
-->  
-->  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
-->  

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]