xsl-list
[Top] [All Lists]

Re: [xsl] Compound filter in for-each

2009-03-27 13:32:24
Wendell Piez <wapiez(_at_)mulberrytech(_dot_)com> 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[(_at_)name='location_name']/value"/>,
   <xsl:value-of select="ExtendedData/Data[(_at_)name='grid_ref']/value"/>,
   <xsl:value-of select="ExtendedData/Data[(_at_)name='rdb_status']/value"/>,
   <xsl:value-of select="ExtendedData/Data[(_at_)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




--~------------------------------------------------------------------
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(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>