xsl-list
[Top] [All Lists]

RE: [xsl] Compound filter in for-each

2009-03-27 08:08:19
OK, I think I have worked this out (and in the process have 
gained more understanding of what you and Michael have been 
trying to explain). 

To re-state: My XML (derived from KML) looks basically like this (some
editing):

<?xml version="1.0" encoding="UTF-8"?>
<kml>
  <Document>
      <Folder>
              <name>Acer campestre</name>
              <Placemark id="rpr_1">
                      <name>Acer campestre</name>
                      <ExtendedData>
                                       <Data name="grid_ref">
                                      <value>SN593798</value>
                              </Data>
                              <Data name="eng_name">
                                      <value>Field Maple</value>
                              </Data>
                              <Data name="rdb_status">
                                      <value>Lower risk - least
concern</value>
                              </Data>
                              <Data name="location_name">
                                      <value>Penparcau</value>
                              </Data>
                              <Data name="last_seen">
                                      <value>**/**/2000</value>
                              </Data>
                      </ExtendedData>
                      <Point>
                              
<coordinates>-4.069436,52.398051,0</coordinates>
                      </Point>
              </Placemark>
      </Folder>
</Document>
</kml>

<Folder> and <Placemark> are repeated

I want to display (in csv format) the values of certain child 
nodes of <Placemark> but (and this was the issue) in certain 
circumstances I want to select out only data from Placemarks 
where <Data name ='rdb_status'> and <Data/value='Endangered'>.

So, this is my solution now (avoiding using xsl:choose):

      <xsl:template match="Folder">
                      <xsl:for-each
select="Placemark[ExtendedData/Data/attribute::name='rdb_statu
s' and ExtendedData/Data/value='Endangered']">

I suspect this still isn't quite right. I suspect you want rdb_status and
Endangered to be present together on the same Data element, whereas you are
selecting any Placemark that has some Data with @name='rdb_status' and some
Data (perhaps a different Data) with value='Endangered'. If I'm right, you
want:

<xsl:for-each select="Placemark[ExtendedData/Data[(_at_)name='rdb_status' and
value='Endangered']]">

Michael Kay
http://www.saxonica.com/


--~------------------------------------------------------------------
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>