Re: [xsl] Compound filter in for-each

Subject: Re: [xsl] Compound filter in for-each
From: "Alan Hale" <A.Hale@xxxxxxxxxx>
Date: Fri, 27 Mar 2009 17:31:26 +0000
>>> Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> 16:39 27 March 2009 >>>
Alan,

Right.

 From here, it's a short step to use a template (with Mike's correction):

<xsl:template match="Folder">
   <xsl:apply-templates select="Placemark[ExtendedData/Data
     [attribute::name='rdb_status' and value='Endangered']]"/>
   </xsl:template>

<xsl:template match="Placemark">
   <xsl:value-of select="@id" />,
   <xsl:value-of select="name" />,
   <xsl:value-of select="ExtendedData/Data[@name='location_name']/value"/>,
   <xsl:value-of select="ExtendedData/Data[@name='grid_ref']/value"/>,
   <xsl:value-of select="ExtendedData/Data[@name='rdb_status']/value"/>,
   <xsl:value-of select="ExtendedData/Data[@name='last_seen']/value"/>,
   <br/>
</xsl:template>

Now, this is an improvement only if:

(a) you consider it a cosmetic improvement, or
(b) your problem becomes more complex and you discover you have to do
the same thing with other Placemark elements in other situations.

More refactoring is also possible; for example you could have a
template matching 'Data' elements that would write their 'value'
elements, if you did a lot of that. But again, for a simple case
(especially if it's a single-purpose, one-off stylesheet) that might
be overkill, and you get the idea.

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Ah yes, I get it - thanks again. I also looked today at the links you sent me
on push v. pull processing, which have helped clarify some of this further for
me.

This approach may not give me any immediate advantage but I will probably wish
to do a lot more processing of these type of data in the future so it's useful
to know what the options are (and to begin to understand them).

Cheers
Alan

Current Thread