xsl-list
[Top] [All Lists]

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

2006-07-20 06:31:00

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.

Nope.

Compare the string to the regular expression.
find _each_ (non-overlapping) substring that matches the regexp.
this gives you a sequence of substrings that alternate
matching,non-matching,matching,..
for each item in this sequence, execute the matching or non-matching
branch of the code.


so...

Given the input "3 minutes 57 seconds",

([0-9]+ minutes) matches just once so you get the sequence of strings

("3 minutes","57 seconds")

so execute xsl:matching-substring with . set to "3 minutes" 
producing 180
then execute xsl:non-matching-substring> with . set to "57 seconds"
producing 0

think of doing a regexp replace of a large text and changing all "white"
to "black"
analyze sequence splitsthe text up to a sequnce of strings, that are
alternately "white" or <the stuff betwwen matches>. Your two brances
would then output "black" in the matching case and do a copy-of in the
non matching case and the end result is all occurrences of white get
changed to black.

David

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