Re: [xsl] Accessing a Java Object after instatiating as a variable

Subject: Re: [xsl] Accessing a Java Object after instatiating as a variable
From: Marian Olteanu <mou_softwin@xxxxxxxxx>
Date: Thu, 16 Dec 2004 13:55:09 -0800 (PST)
Why don't you pass the current date (and all the required formating) as a parameter to the
stylesheet? This way, you will have a platform compatible stylesheet (it will work in any
compliant XSLT processor).

--- cfisher@xxxxxxx wrote:

> After reading Michael Kay's Xalan Chapter in the second edition of XSLT,
> backwards and forwards, I have finally been able to instantiate a
> SimpleDateFormat object.  My problem is how to access the object after it
> is in variable form.  Can this be done?  There are component and script
> elements available, however I am unsure as to their final implementation.
> 
> Here is a portion of my stylesheet:
> 
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> xmlns:fo="http://www.w3.org/1999/XSL/Format";
> xmlns:fox="http://xml.apache.org/fop/extensions";
> xmlns:xalan="http://xml.apache.org/xslt";
> xmlns:Math="xalan://java.lang.Math"
> xmlns:date="http://xml.apache.org/xalan/java/java.util.Date";      --->
> Importing the date class into the namespace and declaring a prefix
> xmlns:java_lang="http://xml.apache.org/xalan/java/java.lang";      --->
> Importing the lang package into the namespace and declaring a prefix
> xmlns:format="xalan://java/java.text.SimpleDateFormat">           --->
> Importing the text package into the namespace and declaring a prefix
> 
> 
>     <xsl:variable name="dNow" select="date:new()"/>
>                ---> Successfully creating a date object
>    <xsl:variable name="formatter" select="format:SimpleDateFormat.new('E
> yyyy.MM.dd hh:mm:ss a zz')"/>   ---> Successfully creating a
> SimpleDateFormat object with my own special format
>      <xsl:variable name="dateToday" select="format:format($dNow)"/>
>           ---> Unsuccessfully creating a formatted date (it has the
> standard formatting applied)
> 
> The reason is because the $dateToday variable is created with a
> SimpleDateFormat object that is derived from the standard class and not the
> class I created with the new('format') string.  Without the formatting
> string applied in the constructor the format looks like this; 12/16/04
> 12:32 PM, which is my local setting.  I don't know how to access the
> instance functions in my created object.
> 
> If someone could shed some light on the manner in which the component and
> script elements can be used with Xalan, then this might be the ticket for
> many extensions which would be useful.  I know they can be used, but I have
> yet to find an example that I can get my mind around...
> 
> Thanks,
> 
> Curtis Fisher
> 
> 


=====
Marian
http://www.utdallas.edu/~mgo031000/


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - 250MB free storage. Do more. Manage less. 
http://info.mail.yahoo.com/mail_250

Current Thread