[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Compound filter in for-each
Alan,
At 05:22 AM 3/27/2009, you wrote: <xsl:template match="Folder"> <xsl:for-each select="Placemark[ExtendedData/Data/attribute::name='rdb_status' and ExtendedData/Data/value='Endangered']"> <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:for-each> </xsl:template> 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. Cheers, Wendell ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
|
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
|