Project

Profile

Help

Bug #4168

Updated by Michael Kay about 5 years ago

From Christian Roth on Saxon mailing list: 

 I've tried the below now also with Saxon 9.9.1.2 and see the exact same behaviour as earlier versions of 9.9.x (but NOT e.g. 9.1.x). I think the current (=Saxon 9.9.x) behaviour/result is incorrect, but am not 100% sure. Since I got no reply on my earlier messages (from January) so far, I hope it's ok to ask that question again. 

 I have the situation that the instruction 

 ~~~ 
 <xsl:value-of select="format-dateTime(current-dateTime(), '[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01]Z', 'en', 'AD', ())"/> 

 ~~~ 
 outputs  

 ~~~ 
  [Calendar: AD]2019-01-16T07:51:11Z 
 ~~~ 

 when I'd expect it to output 

 ~~~ 
  2019-01-16T07:51:11Z 
 ~~~ 

 I've found that when the transform specifies a default namespace, the "[Calendar: AD]" string is prepended. If the transform does *not* specify a default namespace, "[Calendar: AD]" string is not prepended. This behaviour in Saxon 9.9.0.2J is different from Saxon 9.1.0.8J in this regard (where "[Calendar: AD]" is never prepended in these two cases). 

 Debugging into the Saxon source code, it looks like the calendar parameter "AD" is treated as being in the default namespace (instead of the null namespace), even though it does not have a prefix. I think this might be a bug when reading the spec for format-dateTime(), which says:  

 "… if it has no prefix then it represents an expanded-QName in no namespace. If the expanded QName is in no namespace, then it must identify a calendar with a designator specified below"[1].  

 In my case, the designator is a lexical QName that has no prefix, and therefore should be treated as one of the designators listed. 

 Here's my transform testbed: 

 —snip— 
 ~~~ 
 <xsl:stylesheet  
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
 xmlns="http://www.idpf.org/2007/opf" 
 version="2.0"> 

 <xsl:template match="/"> 
   <output><xsl:value-of select="format-dateTime(current-dateTime(), '[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01]Z', 'en', 'AD', ())"/></output> 
 </xsl:template> 
 </xsl:stylesheet> 
 ~~~ —snip— 

 (unexpected) result is: "[Calendar: AD]2019-01-18T14:22:35Z". 

 When removing the default namespace declaration xmlns="http://www.idpf.org/2007/opf" from <xsl:stylesheet>: 

 ~~~ 
 —snip— 
 ~~~ 
 <xsl:stylesheet  
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
 version="2.0"> 

 <xsl:template match="/"> 
   <output><xsl:value-of select="format-dateTime(current-dateTime(), '[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01]Z', 'en', 'AD', ())"/></output> 
 </xsl:template> 
 </xsl:stylesheet> 
 ~~~ 


 
 —snip— 

 (expected) result is "2019-01-18T14:22:35Z". 


 Thanks, 
 Christian 


 [1] https://www.w3.org/TR/xpath-functions-30/#rules-for-datetime-formatting 


Back