[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Accessing a Java Object after instatiating as a variab

Subject: Accessing a Java Object after instatiating as a variable
From: cfisher@xxxxxxx
Date: Thu, 16 Dec 2004 14:03:06 -0600
xsl java object
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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.