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

It's going to work, even if it kills me

Subject: It's going to work, even if it kills me
From: "Tim" <xsl@xxxxxxxxxxxxxx>
Date: 27 Jun 2001 18:29:20 -0000
even if it kills me
Hi Chaps,

I'm still trying to pass a list of keywords in as a parameter and then 
search an xml file for any of those words and return a html formatted 
header list.

An example XML file is:
<articles>
	<article ID="article1">
		<date>
      Tue Jun 19 10:38:02 BST 2001
        </date>
		<detail>
      Tim has bought a Land Rover, for better or for worse.  There will 
be no more tellings-off from the Better Half about wet dogs in good car.
    </detail>
		<title>
      Tim Buys a Land Rover
    </title>
	</article>
	<article ID="article2">
		<date>    
      Tue Jun 19 10:44:28 BST 2001
    </date>
		<detail>
      Nice car but nothing compaired to Tim's new Landy.
    </detail>
		<title>
      Kirsten Buys a Vauxhall
    </title>
	</article>
</articles>



The XSL snip I'm playing with is:
..snip...
	<xsl:template match="/">
		<xsl:apply-templates select="articles">
                <xsl:with-param name="keywords">
			<xsl:value-of select="$keywords"/>
               </xsl:with-param>
		</xsl:apply-templates>
	</xsl:template>
	
	<xsl:template match="articles">
    		<xsl:param name="keywords"/>
		<xsl:variable name="keywordfrag">
			<xsl:call-template name="keylist">
				<xsl:with-param name="keywords">
					<xsl:value-of 
select="$keywords"/>
				</xsl:with-param>
			</xsl:call-template>
		</xsl:variable>
		
		<xsl:for-each select="article[contains(translate
(detail, $vLower, $vUpper),translate(xalan:evaluate($keywordfrag)//*, 
$vLower, $vUpper))]">
			......do stuff......
		</xsl:for-each>
	</xsl:template>
	
<xsl:template name="keylist">
    <xsl:param name="keywords"/>
    <xsl:variable name="key" 
        select="substring-before($keywords,' ')"/>
    <xsl:choose>
        <xsl:when test="string-length($key) > 0">
            <keyword><xsl:value-of select="$key"/></keyword>
            <xsl:call-template name="keylist">
                <xsl:with-param 
             name="keywords"><xsl:value-of 
             select="substring-after($keywords,' ')"/>
               </xsl:with-param>
            </xsl:call-template>
       </xsl:when>
        <xsl:otherwise>
             <keyword><xsl:value-of select="$keywords"/></keyword>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>
.....snip......

The result of this is that it finds all articles because the call to 
the keylist template does not return an xml fragment, just a list of 
keywords without the spaces.

Idea's would be wonderful.

Thanks,
Tim.

"In theory xsl can do anything, but what exactly is your problem?" - 
David Carlisle, from the XSL-list


 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.