[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Re: xsl:analyze-string explanation needed
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:matching-substring> <xsl:value-of select="60 * xs:integer((substring-before(regex-group(1),' minutes')))" /> </xsl:matching-substring> </xsl:analyze-string> </xsl:variable> <xsl:choose> <xsl:when test="$seconds=''"></xsl:when> <xsl:otherwise><xsl:value-of select="$seconds" /></xsl:otherwise> </xsl:choose> </xsl:template> -- 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) David
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|