xml - Why is this XSLT max simulated function not working -
i not xslt, following known pattern simulate max function xslt 1.0.
edit: know thread subject may confusing, not trying build function, rather simulating same behavior
that is, have following xml:
<cards> <card><updated>2013-05-19t16:18:59z</updated></card> <card><updated>2013-05-19t20:41:59z</updated></card> <card><updated>2013-05-19t18:30:59z</updated></card> </cards> i have following output:
max-updated:2013-05-19t20:41:59z this xslt, it's not working expected:
<xsl:template match="cards"> max-updated:<xsl:value-of select="card[not(../card[updated] > updated)]/updated"/> </xsl:template> but output is:
max-updated:2013-05-19t16:18:59z and seems retrieve first node.
i know first sort ordering , first (or last) position element, more interested on knowing doing wrong.
xslt 1.0 doesn't provide greater-than or less-than comparisons on strings: converts both strings numbers (giving nan) , comparing nan nan gives false.
the way compare strings magnitude in xslt 1.0 xsl:sort - sort elements , choose first/last.
or move xslt 2.0.
Comments
Post a Comment