[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: search against index
Hi. Citando bryan <bry@xxxxxxxxxx>: } } I have a parameter $string } } And I do <xsl:apply-templates select="index[contains(@value,$string)]"/> } } This works great, but I want to do a search with string + string, in } other words given limitations of xslt, a search with multiple contains. } } So for example: } <list> } <index value="a string of values here"> } result } </index> } <index value="another string here"> } result2 } </index> } </list> } } } if $string = "another" } } this returns the second index node, if $string = "another + here" } } then it still returns the second index node, if $string = "string + } here" it returns both nodes. } (...) Try this: <xsl:param name="string" select="''"/> <xsl:template match="list"> <result> <xsl:call-template name="search"> <xsl:with-param name="nodes" select="index"/> <xsl:with-param name="string" select="$string"/> </xsl:call-template> </result> </xsl:template> <xsl:template name="search"> <xsl:param name="nodes" select="/.."/> <xsl:param name="string" select="''"/> <xsl:choose> <xsl:when test="contains($string,'+')"> <xsl:call-template name="search"> <xsl:with-param name="nodes" select="$nodes[contains(@value,normalize-space (substring-before($string,'+')))]"/> <xsl:with-param name="string" select="normalize-space(substring-after ($string,'+'))"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:copy-of select="$nodes[contains(@value,$string)]"/> </xsl:otherwise> </xsl:choose> </xsl:template> Hope this helps you. Regards, Americo Albuquerque ___________________________________________________________________ O SAPO já está livre de vírus com a Panda Software, fique você também! Clique em: http://antivirus.sapo.pt 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
|