[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Compound filter in for-each

Subject: RE: Compound filter in for-each
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 24 Mar 2009 22:03:07 -0000
RE:  Compound filter in for-each
> .... but if I do this:
> 
> <xsl:for-each 
> select="Placemark/ExtendedData/Data[@name='rdb_status' and 
> value='Endangered']">
> 
> I get no error, but also no data returned -even though there 
> are matching values.

You haven't shown what you are doing inside the for-each - perhaps that's
where your error is.

How do you know you have now matched the values? What do you get for

count(Placemark/ExtendedData/Data[@name='rdb_status' and 
        value='Endangered'])

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


> 
> 
> Alan Hale wrote:
> > Wendell Piez wrote:
> >> Alan,
> >>
> >> 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'][.='End
> angered']
> >>
> >> 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.
> > Many thanksWendell
> >
> > However I still get the same "Input string was not in a correct 
> > format" with XML Notepad, using either of your suggestions. 
> I'm sorry 
> > I did not give sufficient background information. Happy to provide 
> > more but I'm not clear what type of further info might be needed.
> >
> > I notice some "=" signs went missing in my XML example - I 
> guess you 
> > realised this. Should be like this of course:
> >
> > <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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.