Hi, On 2012-06-25, Cerstin Mahlow <cerstin.mahlow@unibas.ch> wrote:
So my idea was to have the original Text-DB (without whitespace) and the new Text-DB (with whitespace), lets call it Text-DB-WS. All nodes in Text-DB have corresponding nodes in Text-DB-WS, they only differ concerning the node-id. So I should be able to detect which node-id of Text-DB corresponds to which node-id of Text-DB-WS. And then I could create a new version of Collect-DB by replacing the value of all "node" elements with the respective node-id from Text-DB-WS.
I think this is doable. As you're only interested in *element* nodes (<p> and <l>), we can be certain that any node in Text-DB is also in Text-DB-WS, and that the path to a particular node in both databases is identical. Here's my go at it. For simplicity, the variable $nodes contains the information that would actually come from Collect-DB. --8<---------------cut here---------------start------------->8--- xquery version "3.0"; declare option output:separator '\n'; declare variable $bad := db:open('Text-DB'); declare variable $nodes := <nodes><id>499</id><id>713</id></nodes>; for $id in $nodes//id let $path := replace(db:open-id($bad, $id)/path(), 'Q\{.*?\}', '*:') return $id || ' → ' || xquery:eval('db:node-id(db:open("Text-DB-WS")' || $path || ')') --8<---------------cut here---------------end--------------->8--- Apparently the return value from path() is not a valid XPath expression; as a workaround I simply replace the "Q{...}" namespace stuff with "*:". But I'm not an XQuery hacker, so there's probably a better way... In any case, the above code works on my test database. HTH and greetings -- Dr.-Ing. Michael Piotrowski, M.A. <mxp@cl.uzh.ch> Institute of Computational Linguistics, University of Zurich Phone +41 44 63-54313 | OpenPGP public key ID 0x1614A044 * OUT NOW: Systems and Frameworks for Computational Morphology * <http://www.springeronline.com/978-3-642-23137-7>