xsl-list
[Top] [All Lists]

RE: [xsl] xsl:analyze-string explanation needed

2006-07-20 08:02:45
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/


--~------------------------------------------------------------------
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>
--~--