IDREF introduces a validation constraint that a value of the attribute must
correspond to the value of an ID-type attribute somewhere in the same XML
document. Once you have separated the two documents, you will get an error
from a parser that performs DTD validation.
This may be why it "doesn't work," but it's impossible to say for sure
since you don't say what it means for it to work. Work in what processor,
with what other scripts/stylesheets, etc.? All depends on the processes
invoked, and in particular whether they validate.
Ordinarily, you'd solve the problem by changing the IDREF attribute to type
NMTOKEN or CDATA, and rely on some other mechanism besides ID/IDREF
validation (which only scopes within a single document at any rate) to
ensure referential integrity. This is done all the time.
Declaring your second file as an entity in the first file will only have an
effect if you also invoke it or refer to it, in which case it won't be a
separate document at all, but will be called into the first document as if
it were sitting in the same file all along. You haven't said enough to
indicate whether this is what you want.
So you need to be more specific about what environment and tools you are
using in order to know the solution to the problem. For it to "work" is
more than for it to be valid against a DTD, isn't it? This may require a
change to a stylesheet, for example, as well as to a DTD. Or your
browser/processor may simply not support cross-file linking like this.
At 02:13 AM 8/11/00 +0100, you wrote:
>I have an xml file that contains two elements:
>First one with an ID attribute set to something, e.g. "C0000"
>and second element that has an attribute whose value is a link to first
>element via IDREF.
>When I run this xml file with both elements in 1 file, it works and I see
>the link and everything.
>Now, I need to put these two elements in two different xml files and make
>it still work, e.g. file1.xml and file2.xml
>where file1.xml contains 1st element and file2.xml contains 2nd element.
>In file2.xml, I tried setting the link for second element
>using "file1.xml#C0000" instead of "C0000" which is in the case of 1 flat
>xml file, but it keeps complaining about ID "file1.xml#C0000" not defined.
>I even included file1.xml inside file2.xml via ENTITY and then
>used "C0000", but still complaining.
>Any idea what could be wrong here?
Wendell Piez mailto:[log in to unmask]
Mulberry Technologies, Inc. http://www.mulberrytech.com
17 West Jefferson Street Direct Phone: 301/315-9635
Suite 207 Phone: 301/315-9631
Rockville, MD 20850 Fax: 301/315-8285
Mulberry Technologies: A Consultancy Specializing in SGML and XML