xsl-list
[Top] [All Lists]

Re: [xsl] difference between an integer and current-dateTime()

2020-03-28 07:02:20
It should be xsl:value-of, not xs:value-of.

As written, xs:value-of is a literal result element, which finds its way into 
the result tree, but is then discarded on serialization because that's what the 
text output method does with element nodes.

Michael Kay
Saxonica

(Had me puzzled for a while...!)

On 28 Mar 2020, at 00:23, Mukul Gandhi 
gandhi(_dot_)mukul(_at_)gmail(_dot_)com 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:

Hi Martin,
   Thanks for reply.

On Fri, Mar 27, 2020 at 5:35 PM Martin Honnen 
martin(_dot_)honnen(_at_)gmx(_dot_)de 
<mailto:martin(_dot_)honnen(_at_)gmx(_dot_)de>

I've tried following XSLT stylesheet upto now, based on your suggestions,

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform 
<http://www.w3.org/1999/XSL/Transform>"
                         xmlns:xs="http://www.w3.org/2001/XMLSchema 
<http://www.w3.org/2001/XMLSchema>"
                         exclude-result-prefixes="xs"
                         version="3.0">
                
    <xsl:output method="text"/>                
                
    <xsl:param name="secsSinceEpoch" as="xs:integer"/>                
    
    <xsl:template match="/">
       <xsl:variable name="epochDateTime" 
select="xs:dateTime('1970-01-01T00:00:00Z') + 
                                                                              
   xs:dayTimeDuration('PT' || $secsSinceEpoch || 'S')" 
                                                                              
   as="xs:dateTime"/>
       <xsl:variable name="diffDTduration" select="current-dateTime() - 
$epochDateTime" as="xs:dayTimeDuration"/>
       <xs:value-of select="$diffDTduration"/>
    </xsl:template>
    
</xsl:stylesheet>

When I invoke above stylesheet, as follows (using Saxon 10),

java -classpath saxon-he-10.0.jar net.sf.saxon.Transform -s:trf1.xsl 
-xsl:trf1.xsl secsSinceEpoch=1585039138

I get nothing into the output (i.e, <xs:value-of select="$diffDTduration"/> 
doesn't print anything). Any thoughts, how can I proceed further?

But there looks to be a valid value within the variable,  'epochDateTime'.
 


-- 
Regards,
Mukul Gandhi
XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/293509> (by 
email <>)
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>