[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Building select-clause dynamically with parameters

Subject: Building select-clause dynamically with parameters
From: Marko Petersen <lg002237@xxxxxxxxxxxxxxxx>
Date: Tue, 10 Dec 2002 20:39:48 +0100
build where clause
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>&#160;</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



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.