There are no standard tools that I know of to check for the uniqueness
of keys across documents. Similarly, there are no standard tools to
check for referential integrity (validity of pointers / key references)
Instead, you must enforce this in your own application. In your case,
this is fairly simple. For example, first read MOVIES and build a
hashtable of movie IDs. Now read ACTORS and build a hashtable of actor
IDs. Finally, read MOVIESACTORS and, as you read each movie or actor ID,
check that it exists in the correct hashtable.
I'm curious why you want to enforce this in your XML documents. If you
are using XML as a data transport and are storing the data in a
relational database, the database will check this for you when you
insert each row of data from MOVIESACTORS.xml into the database.
On the other hand, one reason to check this is that you are storing your
data in XML documents. This is usually a bad idea. XML documents are a
very inefficient way to store data you have to parse them to access the
data. (Native XML databases usually store documents in pre-parsed form.)
Using XML as a database has lots of other problems as well -- no
indexes, no transactions, no security, no concurrent access, etc.
Luis Abreu wrote:
> Hello all.
> Suppose that you have the following tables:
> - ID
> - Title
> - Year
> - ID
> - FirstName
> - LastName
> - ID
> - Actor
> - Movie
> If i could implement this on a single XML file, there would not be any
> problem, because I could use key/keyref elements on my schema to
> insure that the value of Actor and Movie (MOVIESACTORS) exist on the
> ID elements of Movies and Actors. However, in this case, I want to
> separate this info stored on several files (because if I put everything on
> one file, it turns out that the file is to huge to be parsed on a
> timely manner).
> So, here's my question: can I use key/keyref when the elements are on
> different files? (I think not, but...) If not, how should I proceed?
> In any case, I would really appreciate if someone could give some
> links on how to solve this problem.