HI --
In the process of trying to find the differences between two collections of schemas (the XML differences, as opposed to the not-semantically-meaningful differences in the order of the definitions), I find myself wanting to stick UIDs on everything. (So I can go "oh, this element node is different, but it has descendant elements UIDs also in the list of differences, I don't want this one, the descendants are more precise" (because if I don't do something like this, I'm getting xsd:schema every time...))
I haven't done anything with updating expressions before.
By itself, in the GUI,
for $x in /descendant-or-self::* return insert node(attribute UID {generate-id($x)}) into $x
works. Since I would like everything in one query, with a little flailing I've got as far as
let $new as document-node()+ := for $each in db:open($newName) return copy $temp := $each modify ( for $x in $temp/descendant-or-self::* return insert node(attribute UID {generate-id($x)}) into $x ) return $temp
return $new
And there are all the elements with UID attributes associated with them.
Is there a better way to do this?
Thanks! Graydon
Is there a better way to do this?
Your query could probably be shortened as follows:
let $new := db:open($newName) update { .//* ! (insert node attribute UID { generate-id() } into .) } ...
It does the same as your original query. But maybe you were asking for a better solution to compare documents against each other?
Hi Christian --
I was after a better, or at least less convoluted, way to add the UID attribute nodes. Your code snippet works in place, and faster; thank you!
If anyone happens to have a good general case structure-but-not-position document compare algorithm lying around, I'd be delighted to hear about it. (It can't be just XSD because there's a pile of WSDL documents, too. And who knows what in the future.)
Thanks! Graydon
On Tue, Oct 18, 2016 at 3:28 PM, Christian Grün christian.gruen@gmail.com wrote:
Is there a better way to do this?
Your query could probably be shortened as follows:
let $new := db:open($newName) update { .//* ! (insert node attribute UID { generate-id() } into .) } ...
It does the same as your original query. But maybe you were asking for a better solution to compare documents against each other?
Dependent on your goals, perhaps variations on the theme of a sorted list of all data paths might be useful? For example: considering the paths of all simple elements and attributes, including indexes, and representing text content as an appended last "step" - à la /a[1]/b[2]/c[2]#my text value. I use this in test cases, comparing expected and found instances of complex structures; with any difference expressed in terms of (a) paths only in A, (b) paths only in B, (c) paths in both but with different text value.
Graydon Saunders graydonish@gmail.com schrieb am 14:38 Mittwoch, 19.Oktober 2016:
Hi Christian -- I was after a better, or at least less convoluted, way to add the UID attribute nodes. Your code snippet works in place, and faster; thank you! If anyone happens to have a good general case structure-but-not-position document compare algorithm lying around, I'd be delighted to hear about it.(It can't be just XSD because there's a pile of WSDL documents, too. And who knows what in the future.) Thanks!Graydon On Tue, Oct 18, 2016 at 3:28 PM, Christian Grün christian.gruen@gmail.com wrote:
Is there a better way to do this?
Your query could probably be shortened as follows:
let $new := db:open($newName) update { .//* ! (insert node attribute UID { generate-id() } into .) } ...
It does the same as your original query. But maybe you were asking for a better solution to compare documents against each other?
basex-talk@mailman.uni-konstanz.de