Hi.
Citando bryan <bry(_at_)itnisk(_dot_)com>:
}
} 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