|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Building select-clause dynamically with parameters
Hi,
I would like to pass some words into my XSL file which should be used to build an XPath query in xsl:apply-templates. For an example, the following works, but only for one word: <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" <xsl:param name="query"/> <xsl:template match="/"> <xsl:apply-templates select="chapter[contains(descendant-or-self::*,$query)]"/> </xsl:template> <xsl:template match="chapter | section"> <table> <tr> <td> </td> <td>Found <xsl:value-of select="title"/> <xsl:apply-templates select="section[contains(descendant-or-self::*, $query)]"/> </td> </tr> </table> </xsl:template> </xsl:stylesheet> I don't know how many words will be passed into the XSL file, this should be flexible. For example, If $query has the value "word1 word2", the only chapters and sections that should be selected by apply-templates are those which contain word1 or word2, I think in this case need I something like: <xsl:apply-templates select="chapter[contains(descendant-or-self::*,'word1') or contains(descendant-or-self::*,'word2')]"/> I tried to pass the whole string used by "select" as parameter, but it does not work. Another thing is that I also have words that should be excluded and that I would like to pass a value into the XSL file that should define if it is an AND or an OR query to build something like: <xsl:apply-templates select="chapter[contains(descendant-or-self::*,'word1') and contains(descendant-or-self::*,'word2') and not(contains(descendant-or-self::*,'word3'))]"/> Has anyone an idea how to do something like this? Or is it a better solution to do this with Java DOM? Thanks for help and greetings, Marko 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
|

Cart








