[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: newbie - parameters with/without values??
Hi Hardy,
I will try explaining. The [something] is a filter. A <xsl:for-each select="person"> would select all person elements (that are children of the current element). When you filter it with "person[gender = $gender]" you say that the processor must only select those person elements that have a child element with the value in the variable $gender. Here you have a syntax error as you have written [gender = '$gender'] which says that the element gender (which is a child of person) must have a string value of "$gender". That would be the same in many other programming languages as the difference between (shown in JavaScript syntax) var a = "This"; var b = a; ~ gender = $gender var b = "a"; ~ gender = "$gender" If the filter is true for all elements, then it is the same as having no filter: <xsl:for-each select="person[1=1]"> is the same as <xsl:for-each select="person"> and if the filter is an absurdity (false for all elements), ie. <xsl:for-each select="person[1=0]"> then no elements are chosen. So in your expression (syntax error corrected): <xsl:for-each select="person[$gender='' or gender=$gender]> If $gender is the default, then the first expression will always be true, and every person (element) is then chosen. If, as you said, $gender is 'Male' then the first expression is false, and the second expression will only be true in the example that you mentioned (the Joe person). I hope that this helps. Regards, Ragulf Pickaxe :-) From: "Hardy Merrill" <HMerrill@xxxxxxxxxxxxxxxx> Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>,<mike@xxxxxxxxxxxx> Subject: RE: newbie - parameters with/without values?? Date: Mon, 04 Oct 2004 13:01:00 -0400 _________________________________________________________________ Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
|
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
|