ballsteve / xrust

XPath, XQuery, and XSLT for Rust
Apache License 2.0
89 stars 9 forks source link

Function current-time() is not deterministic. #104

Open Devasta opened 2 months ago

Devasta commented 2 months ago
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0">
  <xsl:mode on-no-match="shallow-copy"/>
  <xsl:output method="xml"/>

  <xsl:template match="/" name="xsl:initial-template">
    <result>
      <current-time1><xsl:value-of select="current-time()"/></current-time1>
      <current-time2><xsl:value-of select="current-time()"/></current-time2>
    </result>
  </xsl:template>
</xsl:stylesheet>

returns

<result>
<current-time1>20:32:11.409495600</current-time1>
<current-time2>20:32:11.410039600</current-time2>
</result>

As per the xpath functions spec the current-time() function sis deterministic.

Seems like we might want to have a struct somewhere during the evaluation step that stores such function call results for future lookups.