Subject: RE: xsl:analyze-string explanation needed
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 20 Jul 2006 16:02:25 +0100
|
> Looking at it, I see the general form as:
>
> Compare the string to the regular expression.
> If there is a match, output something.
> If there is no match, output something else.
No, it's better described as: divide the string into a sequence of strings
some of which match the regex and others which don't. Then process all the
substrings in turn, appling the matching-string instruction to the matching
substrings and the non-matching-substring instruction to the others.
Try:
<xsl:variable name="duration" as="xs:dayTimeDuration"
select="xs:dayTimeDuration(concat('PT', translate(replace($in, '
([ms])[a-z]+ ', '$1'), 'ms ', 'MS')))"/>
<xsl:variable name="seconds" as="xs:integer"
select="$duration div xs:dayTimeDuration('PT1S')"/>
Michael Kay
http://www.saxonica.com/
|