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

xsl:analyze-string explanation needed

Subject: xsl:analyze-string explanation needed
From: cknell@xxxxxxxxxx
Date: Thu, 20 Jul 2006 09:20:22 -0400
 xsl:analyze-string explanation needed
I'm running a stylesheet to perform a statistical analysis of a series of runs on an Ant build.xml file. One of the tasks is to extract the timing information from a number of elements in the log file. The timing information is presented in an attribute in this format: "3 minutes 57 seconds".

I pass this string as a parameter to three named templates to convert the time information into the same units, viz., seconds. Below is one of these templates. The problem I have is, apparently, a faulty mental model of the functioning of  xsl:analyze-string.

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.

Given the input "3 minutes 57 seconds", I expect the output of this template to be "180". Instead, the output is "1800", that is to say, a concatenation of the values produced in each of the two branches, rather than one or the other.

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?


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

Charles Knell
cknell@xxxxxxxxxx - email

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.