最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

xslt - Extracting Timezone Using format-time in Saxon EE 11.4 - Stack Overflow

programmeradmin5浏览0评论

I can't seem to use format-time to extract the current timezone in Saxon EE 11.4.

<!-- Internal error evaluating template rule at line X -->
<xsl:value-of select="format-time(current-time(), '[z]')" />

Instead of returning something such as GMT -07:00 the application crashes with the error message: "Internal error evaluating template rule at line X."

It seems as if other timezone functions are working correctly, and are unaffected:

<!-- Outputs: -PT7H --> 
<xsl:value-of select="implicit-timezone()" />

<!-- Outputs: -PT7H -->
<xsl:value-of select="timezone-from-dateTime(current-dateTime())" />

<!-- Outputs: -PT7H -->
<xsl:value-of select="timezone-from-date(current-date())" />

<!-- Outputs: -PT7H -->
<xsl:value-of select="timezone-from-time(current-time())" />

I can't seem to use format-time to extract the current timezone in Saxon EE 11.4.

<!-- Internal error evaluating template rule at line X -->
<xsl:value-of select="format-time(current-time(), '[z]')" />

Instead of returning something such as GMT -07:00 the application crashes with the error message: "Internal error evaluating template rule at line X."

It seems as if other timezone functions are working correctly, and are unaffected:

<!-- Outputs: -PT7H --> 
<xsl:value-of select="implicit-timezone()" />

<!-- Outputs: -PT7H -->
<xsl:value-of select="timezone-from-dateTime(current-dateTime())" />

<!-- Outputs: -PT7H -->
<xsl:value-of select="timezone-from-date(current-date())" />

<!-- Outputs: -PT7H -->
<xsl:value-of select="timezone-from-time(current-time())" />
Share Improve this question edited Apr 1 at 0:40 Austin asked Apr 1 at 0:39 AustinAustin 11 bronze badge New contributor Austin is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct. 1
  • 1 No idea why this should be failing, but please first try it on a more recent release, and if you still get a failure then raise a ticket at saxonica.plan.io with a full stacktrace of the crash and the full stylesheet. – Michael Kay Commented Apr 1 at 9:38
Add a comment  | 

1 Answer 1

Reset to default 0

The current Saxon 11 release is 11.6, there, with the simplest test, I get no error but a result:

PS C:\Users\marti> java -cp 'C:\Program Files\Saxonica\SaxonEE11-6J\saxon-ee-11.6.jar' net.sf.saxon.Query -qs:"format-time(current-time(), '[z]')"
<?xml version="1.0" encoding="UTF-8"?>GMT+02:00

The same with 11.5, and also with 11.4 EE:

PS C:\Users\marti> java -cp 'C:\Program Files\Saxonica\SaxonEE11-4J\saxon-ee-11.4.jar' net.sf.saxon.Query -qs:"format-time(current-time(), '[z]')"
<?xml version="1.0" encoding="UTF-8"?>GMT+02:00

Now simplest XSLT based on your sample:

<xsl:stylesheet xmlns:xsl="http://www.w3./1999/XSL/Transform" version="3.0">

<xsl:template match="/" name="xsl:initial-template">

   <xsl:value-of select="format-time(current-time(), '[z]')"/>

</xsl:template>

</xsl:stylesheet>

No error but a result:

PS C:\Users\marti> java -jar 'C:\Program Files\Saxonica\SaxonEE11-4J\saxon-ee-11.4.jar' -it -xsl:.\OneDrive\Documents\xslt\blog-xslt-3-by-example\format-time-test1.xsl
<?xml version="1.0" encoding="UTF-8"?>GMT+02:00
发布评论

评论列表(0)

  1. 暂无评论