[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: pattern matching in xslt
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 At 13:32 23/4/02, David Nelson wrote: >I would sincerely apprec. any help you might offer. What I need to do is >tokenize a node value into chunks, filter the trash and return in the xml, >the new clean string. I'm a newbie with xslt and am having a tough time >deciphering how to accomplish this. This (string processing) is not XSLT's strong suit, which is probably why you're having trouble finding the cookbook solution. There are two ways to approach it. One, which is probably more efficient, is to use extension functions; you can just access the various Java string functions directly. The "pure" way to do it is to use a recursive function; something like <xsl:template match="description"> <xsl:call-template name="process-text"> <xsl:with-param name="string" select="."/> </xsl:call-template> </xsl:template> <xsl:template name="process-text"> <xsl:param name="string" select="''"/> <xsl:choose> <xsl:when test="not(contains($string, '.. '))"> <xsl:value-of select="$string"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="substring-before($string, '.. ')"/> <xsl:call-template name="process-text"> <xsl:with-param name="string" select="substring-after($string, '.. ')"/> </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:template> ~Chris - -- Christopher R. Maden, Principal Consultant, crism consulting DTDs/schemas - conversion - ebooks - publishing - Web - B2B - training <URL: http://crism.maden.org/consulting/ > PGP Fingerprint: BBA6 4085 DED0 E176 D6D4 5DFC AC52 F825 AFEC 58DA -----BEGIN PGP SIGNATURE----- Version: PGP Personal Privacy 6.5.8 iQA/AwUBPMXKYaxS+CWv7FjaEQJQOQCfVA0sWrqO0ZdVkbxLIwzFLuiHvewAoPaC EwQ05fb7zzln0OwosWigNEO5 =m9AW -----END PGP SIGNATURE----- XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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
|