Hi all, Related to this post -- does this mean that I cannot write an XPath query that selects based on the value of an element? For example (see the below document), say I want to select the <header> element only when the value of <isModified> is false.
It seems that I cannot do this - e.g. selecting "/session/header[isModified='false']" yields no result on the below document because it seems that "isModified=" will always compare against the entire isMOdified document whose value in this case is: <isModified xmlns:src="http://xml.apache.org/xindice/Query" src:col="/db/catie_3 3eecca6-6921-44d2-a191-861a77bc5d82/session_xml" src:key="841c44e9-54b9-4204-b0d 2-f7bf0ed81426">false</isModified> Does anyone have a workaround for this other than parsing and then doing filtering and sorting on the isModified node in Java? If I made the <isModified> element into an attribute on <header> could I query against it? The contains function doesn't seem to work either ("/session/header/isModified[contains('false')]/header")... Hope you can help -- thank you!! catie <!-- ENTIRE DOC ------> <?xml version = "1.0" encoding = "UTF-8"?> <session> <header> <jasperId>841c44e9-54b9-4204-b0d2-f7bf0ed81426</jasperId> <jasperType>SESSION</jasperType> <moduleId>4343c08c-9903-463a-87e3-ed2191e7e302</moduleId> <nativeId>NULL</nativeId> <isModified>false</isModified> <title>Session titles don't matter</title> </header> <components> <pluggableComponentId>2664b712-5bf8-4b32-86e1-8a54068652cd</pluggableCom ponentId> <pluggableComponentId>c9b5c41a-1779-4f86-b4f8-db9c78c924bd</pluggableCom ponentId> </components> </session> List: xindice-users Subject: RE: XPath details [Repeat Posting] From: "Jayaram Narayana" <[EMAIL PROTECTED]> Date: 2002-04-26 9:46:08 [Download message RAW] mark, carsten and dawid, thanks a ton guys, for your answers. i am StringTokenizing and parsing the xpathquery result. finally! only now i am positive that what i knew is correct :-) -nani -----Original Message----- From: Mark J. Stang [mailto:[EMAIL PROTECTED] Sent: Thursday, April 25, 2002 11:35 PM To: [email protected] Subject: Re: XPath details [Repeat Posting] nani, The result of an XPathQueryResult is a document. You have to parse that resulting document to get your result. The result will contain the key that matches your XPath Query. If you search on an attribute, you will get back the element that contains that attribute. Therefore, a search on //*/[EMAIL PROTECTED] will return an XML document that contains the <ccc value="Hello"></ccc> the collection it came from and the key to the document that contains the element. You will have to parse the document to get the key and the "attributes">. Since the format is the same, this can be done fairly easily with a SAX parser. I know of no other way, nature of the beast... HTH, Mark Jayaram Narayana wrote: > ============================================================= > this question has been posted to the xindice dev. forum also. > ============================================================= > > hi there, > > using an xpath query returns a lot more information than what's actually > required. example, given an element that looks like this: > > <aaa> > <bbb> > <ccc value = "Hello"> > </aaa> > > and an xpath query like this: > "//ccc [EMAIL PROTECTED]" > > will return a big result like this: > > <aaa xmlns:src="http://xml.apache.org/xindice/Query" src:col="/db/zzz/yyy" > src:key="eee"> > <ccc value="Hello" /> > </aaa> > > all i am interested in is the value of the attribute "value" (Hello). how > can i get JUST that directly, and nothig else? i do not want to parse the > DOM for this. > > TIA,
