This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Xalan Java Extension questions.
- To: XSL-List at lists dot mulberrytech dot com
- Subject: [xsl] Xalan Java Extension questions.
- From: "Sudhir Malhotra" <sudhirmalhotra123 at hotmail dot com>
- Date: Fri, 13 Apr 2001 15:51:36 -0500
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi:
I would highly appreciate any suggestions, or pointers to web based
resources or java/xsl code samples. I have gone through Xalan-Java
extensions examples.
----------INPUT XML-------------
<?xml version="1.0" encoding="UTF-8"?>
<reply>
<source name="NYSE">
<entries grouping="instrument" numberOfTimeUnits="60" resultTZ="ET"
segmentEnd="15:00:00" segmentStart="08:30:00"
timeRangeEnd="20000929-15:00:00 ET" timeRangeStart="20000929-09:30:00 ET"
timeUnit="minutes">
... Lots of other stuff ...
</entries>
</source>
</reply>
----------INPUT XML end------------------------
I would like to instantiate java Date object
in my java code as follows.
-----------JAVA CODE snippet----------------------
// This is just sample code to show our approach
public void transformInputXml()
{
Date timeRangeStart;
// source has Input XML
// target has Output XML
// transformer uses createOutputAndGetStartDate.xsl
createOutputAndGetStartDate = new StreamSource(new File(
createOutputAndGetStartDate.xsl ));
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer
(createOutputAndGetStartDate);
transformer.transform(source, target);
// I am able to get my target XML
// I can create the timeRangeStart Date object
// inside createOutputAndGetStartDate.xsl
// QUESTION 1. : I do not
// know how to get the Date object created in XSL context
// back to Java context and so that it prints
// "September 29, 2000 ... " per the next line.
// I am constrained not to make timeRangeStart static.
// I my case I need the transformation to go on
// to plot the stock prices coming from the market, and
// I need also need the Date value returned to me
// in the java context, without
// making another call through the transformer
System.out.println ( timeRangeStart.toString() );
// QUESTION 2. : How to create a complex object in Java
// context and pass it to xsl
// I am able to pass a string object
// transformer.setParameter("PersonName", "Joe" );
// <xsl:param name="PersonName" select="anonymous"/>
// How to pass a Person object, containing all its
// members?
// QUESTION 3.
// In case the Input XML is an error response instead
// of the data requested, I need to capture the
// Error code and reason per the INPUT XML 2 below.
// Currently I get TransformerException.
// I added the following lines to xsl
// <xsl:template match="reply/source/Error">
// <xsl:message terminate="yes"/>
// <!--<xsl:text><xsl:value-of select="@reason"/></xsl:text>-->
// <xsl:text>Error received from source</xsl:text>
// </xsl:template>
// I am not able to get the @reason value back to Java context
// so that I can inform the user what happened.
// Neither can I get the error message I inserted within xsl:text
// tag
}
------------JAVA CODE Snippet end-------------
----------INPUT XML 2------------------
<?xml version="1.0" encoding="UTF-8"?>
<reply>
<source name="NYSE">
<Error code="-300" reason="Connection failed" />
</source>
</reply>
----------INPUT XML 2 end------------------------
Any help would be greatly appreciated.
Thank you.
Sudhir Malhotra
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list