[xsd-users] sequence copy and xsd:IDREF

Sumant Tambe sutambe at dre.vanderbilt.edu
Wed Oct 29 16:53:25 EDT 2008


Hi Boris,

Agreed that making copies of xml tree is wasteful but isn't copy also 
supposed to have everything from the original? It should be 
indistinguishable from the original and therefore, even IDREF should 
also be present. The IDREF I'm dereferencing points to another book in 
the same sequence which is there in the copy as well. Only thing that is 
missing in the copy of the sequence is the root document element. May be 
implementation of IDREF depends on it.

Thanks,

Sumant.

Boris Kolpackov wrote:
> Hi Sumant,
> 
> Sumant Tambe <sutambe at dre.vanderbilt.edu> writes:
> 
>> I'm getting a seg-fault while trying to access xsd:IDREF attribute in a 
>> *copy* of a sequence. For instance, in the library catalog example, 
>> "recommends" is an xsd:IDREF attribute. The following code seg-faults 
>> when b is a copy but works fine when it is a reference.
>>
>> std::auto_ptr<catalog> c (catalog_ (argv[1]));
>> catalog::book_sequence b = c->book();
>>
>> for (catalog::book_const_iterator bi (b.begin ());
>>      bi != b.end (); ++bi)
>> {
>>   if (ai->recommends ())
>>      cerr << "  Recommends : " << (*ai->recommends ())->title ();
>> }
>>
>> Why is such a difference in the behavior?
> 
> Because when you dereference an IDREF pointer the corresponding 
> ID value is searched in the tree that this object is part of.
> When you use a reference, the sequence is part of the original
> tree and the object with ID in question can be located. When
> you make a copy of the sequence, the copy is on its own and 
> when you try to dereference an IDREF pointer the corresponding 
> ID cannot be found, NULL is returned, and you get a segfault.
> 
> Generally, it makes little sense to make copies of parts of the
> tree since it wastes resources.
> 
> Boris




More information about the xsd-users mailing list