xsl-list
[Top] [All Lists]

RE: Date Difference

2005-12-20 03:05:26
"Haarman, Michael" wrote:

This statement:

    <xsl:variable name="later"
                  select="dateStandard[2]"
                  as="xs:date"/>

seemed to work fine, but this one later:

    <xsl:variable name="regexE" 
      select="fn:replace($earlierPadded,
                         '(.*)/(.*)/(.*)',
                         '$3-$1-$2')
      as="xs:date"/>

threw an error when the value of $regexE was used in the
later arithmetic, complaining that it was still a string.
Stating it in the following manner corrected the error:

    <xsl:variable name="regexE" 
      select="xs:date(fn:replace($earlierPadded,
                                 '(.*)/(.*)/(.*)',
                                 '$3-$1-$2'))"/>

I suspect I am missing an implicit cast somewhere that
makes the first statement work and renders the as=
attribute moot.

  The value of the '@as' don't imply a conversion.

  Because you didn't use SA processor (or at least not their
SA functionalities), '$eaerlierPadded' is still an
'untypedAtomic'.  So it's converted to the expected type
(because it's an 'untypedAtomic') in the first example.

  In the second example, it's converted too, but to an
'xs:string', because it's the expected type of the first
argument of the 3-args 'fn:replace()'.  The result type of
this function is an 'xs:string'.  So it's not converted to
the expected type (because it's not an 'untypedAtomic').

    http://www.w3.org/TR/xslt20/#variables
    http://www.w3.org/TR/xslt20/#dt-function-conversion-rules
    http://www.w3.org/TR/xpath20/#id-function-calls

--drkm




















        

        
                
___________________________________________________________________________ 
Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs 
exceptionnels pour appeler la France et l'international.
Téléchargez sur http://fr.messenger.yahoo.com

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>