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

RE: How to express a select attr in for-each for condi

Subject: RE: How to express a select attr in for-each for conditional or nonconditonal case.
From: "Chris Bayes" <chris@xxxxxxxxxxx>
Date: Thu, 20 Dec 2001 08:04:23 -0000
express select xsl
I see.
Ok you want
<xsl:for-each select="$source[contains($keywrd,.)]|$source[$keywrd='']">


Ciao Chris

XML/XSL Portal
http://www.bayes.co.uk/xml


> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> E100 SFYang
> Sent: 20 December 2001 03:35
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  How to express a select attr in for-each for 
> conditional or nonconditonal case.
> 
> 
> Hi, listers,
> 
> I use contains function to get the selected item defined
> by select attr of param element. such as;
> 
> <xsl:for-each select="$source[contains($keywrd,.)]">
> 
> Of course using this expression for empty param, nothing will 
> be displayed.
> 
> I wonder how to modify the above select att to be able to display
> 
>  1. selected items when keywrd is not empty.
>  2. all items when keywrd is empty.  
> 
> Thanks for any help in advance.
> 
> Sun-fu Yang
> 
> sfyang@xxxxxxxxxxxxx
> 
> ***  simplified xml file  **
> <?xml-stylesheet href="test.xsl" type="text/xsl"?>
> <docs>
> <item>a</item>
> <item>b</item>
> <item>c</item>
> </docs>
> 
> 
> ***   xsl   file  **
> <?xml version='1.0'?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
> <xsl:key name="sourcekey" match="item" use="."/>
> <xsl:variable name="source" 
> select="/docs/item[generate-id(.)=generate-id(key('sourcekey',
> .)[1])]"/>
> <xsl:param name="keywrd" select="'a,b'"/>
> <xsl:template match="/">
> 
> <xsl:for-each select="$source[contains($keywrd,.)]">
> <xsl:value-of select="."/>
> </xsl:for-each>
> </xsl:template>
> </xsl:stylesheet>
> 
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/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.