[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: xsl:analyze-string explanation needed

Subject: Re: xsl:analyze-string explanation needed
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 20 Jul 2006 14:30:46 +0100
Re:  xsl:analyze-string explanation needed
> 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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.