- From: mmstefan <mmstefan@mediaone.net>
- Date: Thu, 19 Jul 2001 10:36:50 -0400
- To: Michael Good <good@recordare.com>
- CC: "'Michael Dyck'" <MichaelDyck@home.com>, www-ql@w3.org
I'll pitch in with my variants: 1. for $p in //part where contains(string($p/note), "CDEC") return $p/note This query assumes that string() takes a sequence of elements. If not, just construct a dummy element, as in: for $p in //part let $foo := <foo>{$p/note}</foo> where contains(string($foo), "CDEC") return $foo/* 2. for $p in //part let $z := (<note>C</note>,<note>D</note>,<note>E</note>,<note>C</note>) where subseq($z, $p/note) return $p/note assuming there is a boolean function subseq() testing inclusion of a sequence in another sequence, based on string value comparison. I consider this version more elegant and a lot more capable to be extended in various ways (for instance, by tweeking subseq() to check for other constraints). I hope that this helps. Frankly, it is exciting to see XML and friends being used in these kind of applications. Mugur Stefanescu Michael Good wrote: > Hello Michael, > > Thank you for letting me elaborate the problem - I left out an important > aspect. We want to match > > <part name="voice"> > <measure number="1"> > <rest/> > <rest/> > <note>C</note> > <note>D</note> > </measure> > <measure number="2"> > <note>E</note> > <note>C</note> > <rest/> > <rest/> > </measure> > </part> > > But not > > <part name="voice"> > <measure number="120"> > <rest/> > <rest/> > <note>C</note> > <note>D</note> > </measure> > </part> > <part name="piano"> > <measure number="1"> > <note>E</note> > <note>C</note> > <rest/> > <rest/> > </measure> > </part> > > So I don't think the following::note XPath will work to exclude the > latter example. Sorry I did not include that aspect in my original > problem. This motivated the general request to restrict the sequence to > a certain level of ancestor - in this case, we a common grandparent - a > common parent is too restrictive, a common great-grandparent too > general. > > And we do need all four notes, because things get more complicated > quickly. In general, we will need to do a fuzzy search and rank the > results for relevance. But for now, I will be happy with something > simple for exact searches that does not give false positives. > > Thanks again, > > Michael Good > Recordare > > -------------------- > > Michael Dyck wrote: > > Hmmm... How about this XPath: > > //note[.="C" > and following::note[1]="D" > and following::note[2]="E" > and following::note[3]="C"] > > That would select the first note of each occurrence of the "Frere > Jacques" > melody in the current document. If (as you say) you want to select all > four > notes of each occurrence of the melody, that would be more involved, I > think.
Received on Thursday, 19 July 2001 10:38:48 UTC