Subject: Re: XSL substrings
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 12 Feb 2009 10:59:59 GMT
|
> <xsl:stylesheet version="1.0"
are you restricted to use xslt 1.0? string handling like this is
approximately 10000000000 times easier in xslt2, where you have regexp
instructions. (xsl:analyze-string is specifically designed to solve your
problem)
However in xslt 1....
> What I want is to get "<Thickness>", which is the number after the
> "T=",
so you want the thing after T= but before a space
so
<Thickness>
<xsl:value-of select="substring-before(substring-after(DIMENSION,'T='),'
')"/>
</Thickness>
<xsl:variable name="size" select="substring-after(DIMENSION,' ')"/>
<Length>
<xsl:value-of select="substring-before($size,'x')"/>
</Length>
<Width>
<xsl:value-of select="substring-after($size,'x')"/>
</Width>
or in xslt2
<xsl:analyze-string select="DIMENSION" regex="\s*T=\s+([0-9)+\s*(0-9)+x(0-9)+\s*">
<Thickness> <xsl:value-of select="regex-group(1)"/></Thickness>
<Length> <xsl:value-of select="regex-group(2)"/></Length>
<Width> <xsl:value-of select="regex-group(3)"/></Width>
</xsl:analyze-string>
David
________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.
This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs.
________________________________________________________________________
|