Subject: Re: [xsl] Multi-part search XPath expressions. From: David Adams <dpadams@xxxxxxxxx> Date: Sat, 11 Sep 2004 14:50:19 +1000 |
> 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Multi-part search XPath e, Bruce D'Arcus | Thread | Re: [xsl] Multi-part search XPath e, Bruce D'Arcus |
Re: [xsl] Multi-part search XPath e, Bruce D'Arcus | Date | [xsl] Using a pre-processor for dyn, David Adams |
Month |