Hi Michael,

Understood for the tricky date problems, especially going so far back what with the proleptic, not to mention the priapic.

As I too often say, "Il y a trop de choix dans les dates!"

And granted that country context is important.  In 1066, was the kingdom won or lost?  

At any rate, these days I happen to be on the "saxon" side, and I'm trying to understand the documentation from "Controller.setParameter()" which says that a java Date type parameter is translated to a xs:dateTime XPath.  But now I'm guessing that this documentation preceded the aforementioned tribulations on dates and so is no longer current.  Too bad as would be a useful shortcut.

thanks for help

-alan and the SocGen gang


public void setParameter(java.lang.String expandedName,
                        java.lang.Object value)

Set a parameter for the transformation.

The following table shows some of the classes that are supported by this method. (Others may also be supported, but continued support is not guaranteed.) Each entry in the table shows first the Java class of the supplied object, and then the type of the resulting XPath value.

Java Class
XPath 2.0 type
String xs:string
Boolean xs:boolean
Integer xs:integer
Long xs:integer
Double xs:double
Float xs:float
BigDecimal xs:decimal
BigInteger xs:integer
Date xs:dateTime






mike@saxonica.com

08/30/06 07:52 PM

To
saxon-help@lists.sourceforge.net
cc
Subject
RE: [saxon] can't pass Date parameters that validate as xs:dateTime





This is in accordance with the specification at
 
http://www.saxonica.com/documentation/extensibility/function-result.html
 
It would be nice to support this mapping, but it's not currently designed into the product (and there's nothing in the JAXP interface that says it should be).
 
There are a number of technical issues here that make it more difficult than one might imagine to take a java.util.Date as input. Your example, new GregorianCalendar(1066, 9, 14), despite appearances, actually represents the date 14 Oct 1066 in the Julian calendar, which corresponds to the date 1066-10-20 in the proleptic Gregoarian calendar used in the xs:dateTime data type. So the conversion isn't trivial, especially as the date for switching from one calendar to the other depends on which country you are in. It would be possible to convert by calling setGregorianChange() on the supplied GregorianCalendar object, but that doesn't work easily because I can't really modify an object supplied by the caller.
 
The XQJ interface for XQuery also struggles with this: it maps an xs:dateTime not to a java.util.GregorianCalendar or java.util.Date object, but to an instance of javax.xml.datatype.XMLGregorianCalendar.
 
Michael Kay
http://www.saxonica.com/


From: saxon-help-bounces@lists.sourceforge.net [mailto:saxon-help-bounces@lists.sourceforge.net] On Behalf Of alan.painter@sgcib.com
Sent:
30 August 2006 16:56
To:
saxon-help@lists.sourceforge.net
Cc:
PAR-ITEC-DFI-FSI-Support@sgcib.com
Subject:
[saxon] can't pass Date parameters that validate as xs:dateTime



Scratching big patchy spot at top of head but unable to figure out this one.


Trying to pass a java.util.Date parameter into a SaxonSA stylesheet and have it validate as an "xs:date" or "xs:dateTime" or any equivalent.


Always getting an error.



Minimal example XSLT: (SaxonParamTest.xslt)


<?
xml version="1.0" encoding="UTF-8"?>
<
xsl:stylesheet xmlns:xs="http://www.w3.org/2001/XMLSchema"
               
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  
               
version="2.0">

       
<xsl:output name="xml" method="xml" omit-xml-declaration="yes" indent="no" />
       
       
<xsl:param    name="dateParam"   as="xs:dateTime"  />

       
<xsl:template match="/">
               
<xsl:message select="'dateParam = '"><xsl:value-of select="$dateParam"/></xsl:message>
       
</xsl:template>

</
xsl:stylesheet>

Called from a minimal example Java (SaxonParamTest.java):


public class SaxonParamTest {

       
   public static final String NULL_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
                                         + "<rootElement/>";


   public final static String jaxpXformFactProp = "javax.xml.transform.TransformerFactory";

   public final static String saxnXformFactImpl = "com.saxonica.SchemaAwareTransformerFactory";


   public static void main(String[] args) throws TransformerException {

               
       System.setProperty(jaxpXformFactProp, saxnXformFactImpl);

       TransformerFactory tfactory = TransformerFactory.newInstance();


       // Create a transformer for the stylesheet.

       Transformer transformer = tfactory.newTransformer(new StreamSource("./src/simpletest/SaxonParamTest.xslt"));

       
       // Add a date parameter

       Date keyDate = new GregorianCalendar(1066, 9, 14).getTime();

       System.out.println(keyDate.toString());

       transformer.setParameter("dateParam", keyDate);


       // Transform the source XML to System.out.

       transformer.transform(new StreamSource(new ByteArrayInputStream(NULL_XML.getBytes())),

                             new StreamResult(System.out));                

   }


}



Getting this error message:


Validation error
 FORG0001: Invalid dateTime value. Non-numeric component


Thanks for any pointers.


-alan



*************************************************************************
This message and any attachments (the "message") are confidential and intended solely for the addressee(s).
Any unauthorised use or dissemination is prohibited. E-mails are susceptible to alteration.   
Neither SOCIETE GENERALE nor any of its subsidiaries or affiliates shall be liable for the message if altered, changed or falsified.
                              ************
Ce message et toutes les pieces jointes (ci-apres le "message") sont confidentiels et etablis a l'intention exclusive de ses
destinataires. Toute utilisation ou diffusion non autorisee est interdite. Tout message electronique est susceptible d'alteration. 
La SOCIETE GENERALE et ses filiales declinent toute responsabilite au titre de ce message s'il a ete altere, deforme ou falsifie.
*************************************************************************