Subject: Re: [xsl] Compound filter in for-each From: Alan Hale <alan.hale@xxxxxxxxxxx> Date: Tue, 24 Mar 2009 20:32:05 +0000 |
Alan,Many thanksWendell
At 02:47 PM 3/24/2009, you wrote:Still working on XML derived from Google Earth KML. I want to filter on
particular ExtendedData/Data name and value combinations. Here is an
extract of relevant XML:
<Placemark>
..................
<ExtendedData>
<Data name "sciencName">
<value>Euphrasia micrantha</value>
</Data>
<Data name "grid_ref">
<value>SN701822</value>
</Data>
<Data name "eng_name">
<value>An Eyebright</value>
</Data>
<Data name "rdb_status">
<value>Endangered</value>
</Data>
.........................
</ExtendedData>
............................
</Placemark>
So I guess what I am looking for is something like:
<xsl:for-each select "Placemark/ExtendedData/Data[@name 'rdb_status'and value
'Endangered']">
- though this doesn't work (in XML Notepad I just get the unhelpful error message "Input string was not in a correct format.")
You might want
select="Placemark/ExtendedData/Data[@name='rdb_status'][.='Endangered']
which is effectively the same as
select="Placemark/ExtendedData/Data[@name='rdb_status' and .='Endangered']
But it's impossible to say absolutely without knowing more about what you haven't told us.
The "." in that expression is short for XPath "self::node()", which is to say a reference to the context node. So ".='Endangered'" is a test for whether the context node of the evaluation (viz., each Data element selected by the path) has the string value "Endangered".
Whether you use one predicate with an "and" operator to join your tests, or two predicates, doesn't make any practical difference here.
<Placemark> .................. <ExtendedData> <Data name = "sciencName"> <value>Euphrasia micrantha</value> </Data> <Data name = "grid_ref"> <value>SN701822</value> </Data> <Data name = "eng_name"> <value>An Eyebright</value> </Data> <Data name = "rdb_status"> <value>Endangered</value> </Data> ......................... </ExtendedData> ............................ </Placemark>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Compound filter in for-ea, Wendell Piez | Thread | Re: [xsl] Compound filter in for-ea, Alan Hale |
Re: [xsl] Pattern question: first c, Wendell Piez | Date | Re: [xsl] Compound filter in for-ea, Alan Hale |
Month |