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

RE: Re: xsl:analyze-string explanation needed

Subject: RE: Re: xsl:analyze-string explanation needed
From: cknell@xxxxxxxxxx
Date: Thu, 20 Jul 2006 09:49:20 -0400
using xsl analyze string
I'm not following you. When you say "... match (or not) the whole string ...", are you saying that I should change the regex so that it matches the entire input string rather than the part I'm interested in, or will adding the "$" cause xsl:analyze-string to deal only with the part I'm interested in using?

I've come up with a solution that feels bulky, but it works. Of course, if I could slim it down, I'd be so much the happier.

Bulky Solution:
<xsl:template name="extract-minutes-as-seconds">
  <xsl:param name="time" />
  <xsl:variable name="seconds">
	  <xsl:analyze-string select="$time" regex="([0-9]+ minutes)">
	  		<xsl:value-of select="60 * xs:integer((substring-before(regex-group(1),' minutes')))" />
		<xsl:when test="$seconds=''"></xsl:when>
		<xsl:otherwise><xsl:value-of select="$seconds" /></xsl:otherwise>

Charles Knell
cknell@xxxxxxxxxx - email

-----Original Message-----
From:     David Carlisle <davidc@xxxxxxxxx>
Sent:     Thu, 20 Jul 2006 14:39:16 +0100
To:       xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Re:  xsl:analyze-string explanation needed

> Can someone explain the operation of this element and how I can get
> the output of either one OR the other branch, but not both? 

make the regex match (or not) the whole string (by adding .*$ to the end of the
regex), and if there is a possibility that the string takes more than one
line, setting the flags to make sure . includes the newline character)


Current Thread


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.
First Name
Last Name
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.