Hello Mansi,
I am a bit unsure what you are actually looking for. As a general strategy, there is now way you can hook into the actual insert functionality. So you will have to write your own function, e.g. something along the lines of
declare function local:add($new as item()) { if (not(local:too-similar($new))) then db:add("my-db", $new) else error() };
If you are asking how to design your similarity function, I guess we can't help you with the given information. Similarity functions are heuristics and there are many ways how to model them. What does "almost identical mean". Is it if just one element is different? Is it if a certain percentage is different? Do you care only about certain elements? I guess you will have to come up with this one on your own, depending on your business requirements.
Cheers, Dirk
On 01/02/2015 05:43 PM, Mansi Sheth wrote:
Hello,
I am trying to come up with a design, which just before insert a xml file into database, will warn us, that there is almost an identical xml file (with different name and different size) already stored in the database.
"Almost identical" would be based on few elements of xml file such as:
<root> <A name=""> <B name=""> <C name=""/> <C name=""/> . . </B> </A> . . . </root>
"A" and "B" from above snippet but different "C". Element "A" could be repeated 100s of time in single xml file.
Any pointers ?
- Mansi