[xsd-users] Obtaining a referenced element via IDREF
Boris Kolpackov
boris at codesynthesis.com
Mon Feb 20 10:02:41 EST 2006
Marco,
Marco Fischer <marco.fischer at chipvision.com> writes:
> Aahh, ok, probably not. You have some generic navigation functionality
> in the underlying classes, used for looking up IDREFS. So all elements
> can be reached, only if they are somewhere on the underlying navigation
> paths, right?
Not necessarily underlying, just if they are in the same tree (formally,
if they have a common root).
> Which actions make elements part of the same tree?
The tree is a container, it maintains ownership of its nodes. When
you call an accessor function you get a reference to the node which
is part of the tree. Modifier functions make copies and store them
in the tree. Here are a couple of examples assuming schemas for
A, B, and C from the previous email:
A a;
B b;
a.name ("foo");
b.ref ("foo");
C c (a, b); // C makes a copy of 'a' and 'b'. 'a' and 'b' are not part
// of the tree with the root being 'c'
A& ra (c.a ()); // ra refers to a copy of 'a' which is part of the tree
B& rb (c.b ()); // ditto
A* p (rb.ref ().get ().get ()); // p is (&ra)
p = b.ref ().get ().get (); // p is 0
B cb (c.b ()); // cb is a copy of (c.b ()) and not part of the tree
p = b.ref ().get ().get (); // p is 0
> If I have a sequence of B's in A called children, would then
>
> A *a;
> B *b;
> ...
> a.children.push_back(b);
>
> make 'b' reachable from 'a', and vice versa?
No, because
a.children ().push_back (b);
will create a copy of 'b'. But
B& rb (a.children ().back ());
will.
hth,
-boris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 652 bytes
Desc: Digital signature
Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20060220/ebf3c12b/attachment.pgp
More information about the xsd-users
mailing list