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
>
Dirk Kirsten, BaseX GmbH, http://basex.org
|-- Firmensitz: Blarerstrasse 56, 78462 Konstanz
|-- Registergericht Freiburg, HRB: 708285, Geschäftsführer:
| Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle
`-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22