Altova Mailing List Archives>Archive Index >xsl-list Archive Home >Recent entries >Thread Prev - [xsl] extracting data from an element [Thread Next] Re: [xsl] extracting data from an elementTo: Date: 2/3/2009 12:32:00 PM Martin Honnen wrote: Mike Stroud wrote: Today I have a different problem. How do I extract data from an element? If you use XSLT 2.0 then look into xsl:analyze-string http://www.w3.org/TR/xslt20/#analyze-string Here is an example: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="xml" indent="yes"/> <xsl:template match="DIMENSIONS"> <xsl:copy> <xsl:apply-templates/> </xsl:copy> </xsl:template> <xsl:template match="DIMENTION"> <xsl:copy> <xsl:analyze-string select="." regex="\s+T=(\d+)\s+(\d+)\s+x\s+(\d+)"> <xsl:matching-substring> <Length> <xsl:value-of select="regex-group(1)"/> </Length> <Width> <xsl:value-of select="regex-group(2)"/> </Width> <Mass> <xsl:value-of select="regex-group(3)"/> </Mass> </xsl:matching-substring> </xsl:analyze-string> </xsl:copy> </xsl:template> </xsl:stylesheet> Note that you use the odd spelling "DIMENTION" in your XML input sample so the match attribute uses that spelling too. -- Martin Honnen http://JavaScript.FAQTs.com/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
