xsl-list
[Top] [All Lists]

Re: [xsl] XSL substrings

2009-02-12 06:00:25


<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. 
________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>