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

Re: Multi-part search XPath expressions.

Subject: Re: Multi-part search XPath expressions.
From: David Adams <dpadams@xxxxxxxxx>
Date: Sat, 11 Sep 2004 14:50:19 +1000
xsl search xpath
> You're going to be surprised how easy it is.
Right you are ;-) Thanks, that's a lot easier to read and write. I've
been experimenting with this and think something else may be coming
clear. The purpose of a select statements in apply-templates is to
select a set of nodes for processing, such as "select all extinct
birds":

	<xsl:apply-templates select='/Australian_Birds/Species[Extinct="Yes"]'/>

Then, the template can have whatever sorts of conditional behavior it
likes based on values within the nodes, such as:

<xsl:template match="Species">
   <xsl:choose>

     <xsl:when test="Extinct='Yes' ">
       <p>Extinct species name is <xsl:value-of select="Common_Name"/></p>
     </xsl:when>

 	 <xsl:when test="Extinct='No' ">
       <p>Living species name is <xsl:value-of select="Common_Name"/></p>
     </xsl:when>

     <xsl:otherwise></xsl:otherwise>
   </xsl:choose>
</xsl:template>

This, then, makes it easy to, for example, first list all extinct
species and then all living species:

 <xsl:template match="Australian_Birds">
	<xsl:apply-templates select='/Australian_Birds/Species[Extinct="Yes"]'/>
	<xsl:apply-templates select='/Australian_Birds/Species[Extinct="No"]'/>
</xsl:template>


I'm still trying to get my head around the language and am now lead
into wondering about subroutines. If I expand the template to include,
for example, Genus and species name in italics, I end up with an
obvious redundancy:

  <xsl:when test="Extinct='Yes' ">
       <p>Extinct species name is <xsl:value-of select="Common_Name"/></p>
	   (<i>
		<xsl:value-of select="Genus_Name"/>
	    <xsl:text> </xsl:text> 
 	    <xsl:value-of select="Species_Name"/>
		</i>)
     </xsl:when>

 	 <xsl:when test="Extinct='No' ">
       <p>Living species name is <xsl:value-of select="Common_Name"/></p>
		 (<i>
		<xsl:value-of select="Genus_Name"/>
	    <xsl:text> </xsl:text> 
 	    <xsl:value-of select="Species_Name"/>
		</i>)
     </xsl:when>

Should I be looking at xsl:call-template to centralize, for example,
this section of the template?
              (<i>
		 <xsl:value-of select="Genus_Name"/>
	        <xsl:text> </xsl:text> 
 	        <xsl:value-of select="Species_Name"/>
            </i>)

Thanks again,

---------------------------------------------
 David Adams
  dpadams@xxxxxxxxx
 Bermagui 2546 NSW
---------------------------------------------

--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx>
--+--

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.