xsl-list
[Top] [All Lists]

Accessing a Java Object after instatiating as a variable

2004-12-16 13:03:06
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


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>