[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Search and replace acronyms
Hi all :)
I'm using the the following template "replace-acronyms" for finding and replacing acronyms in text parts of a document. Exactly more of reusing the text and placing <b> tags around it.. My problem is i need to make a case insensitive search... And use the original text inside <b> tags. What modifications does my template require? <xsl:template match="result"> <a class="big"> <xsl:attribute name="href"><xsl:value-of select="showurl"/></xsl:attribute> <xsl:value-of select="title"/> </a> <div class="articlePar"> <xsl:call-template name="replace-acronyms"> <xsl:with-param name="text" select="dynamicsmell" /> <xsl:with-param name="acronyms" select="match" /> </xsl:call-template> </div> </xsl:template> <xsl:template name="replace-acronyms"> <xsl:param name="acronyms" select="." /> <xsl:param name="text" /> <xsl:choose> <xsl:when test="not($acronyms)"> <xsl:value-of select="$text" /> </xsl:when> <xsl:when test="not(string($text))" /> <xsl:otherwise> <xsl:variable name="acronym" select="$acronyms[1]" /> <xsl:choose> <xsl:when test="contains($text, $acronym)"> <xsl:variable name="before" select="substring-before($text, $acronym)" /> <xsl:variable name="after" select="substring-after($text, $acronym)" /> <xsl:call-template name="replace-acronyms"> <xsl:with-param name="text" select="$before" /> <xsl:with-param name="acronyms" select="$acronyms[position() > 1]" /> </xsl:call-template> <acronym title="{$acronyms[1]}"> <b><xsl:value-of select="$acronym" /></b> </acronym> <xsl:call-template name="replace-acronyms"> <xsl:with-param name="text" select="$after" /> <xsl:with-param name="acronyms" select="$acronyms" /> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:call-template name="replace-acronyms"> <xsl:with-param name="text" select="$text" /> <xsl:with-param name="acronyms" select="$acronyms[position() > 1]" /> </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:otherwise> </xsl:choose> </xsl:template> Part of my xml document i parse: <searchresult total="443" first="1" last="50" dbkey="fionia"> <result> <score value="2.00"/> <title><![CDATA[Kontakt Fionia Bank]]></title> <showurl><![CDATA[http://www.fioniabank.dk/kontakt/Kontakt_lille/]]></showurl> <match>bank</match> <match>fionia</match> <staticsmell><rawstr>psize__##__17062__##____##__pencoding__##__iso-8859-1__##____##__doctype__##__html</rawstr></staticsmell> <dynamicsmell> <![CDATA[ pdf-format. Vedtfgter Hent Fionia Banks vedtfgter i pdf-format her. Fionia Bank A/S 7 Vestre Stationsvej 7 7 5100 Odense C. 7 Telefon 65 20 40 60 E-mail fioniabank@xxxxxxxxxxxxx 7 Copyright ) 2002 Fionia Bank A/S 7 Alle rettigheder forbeholdes. ]]></dynamicsmell> <dates lastmodified="0" /> </result> _________________________________________________________________ Ta' pe udsalg eret rundt pe MSN Shopping: http://shopping.msn.dk - her finder du altid de bedste priser
|
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
|