Weird behavior of XML DB when inserting new elements and trying to read them again -
01-18-2006
, 10:05 PM
Hi,
I have run into a very strange and frustrating problem that I just
haven't been able to nail down. I'm hoping very much that someone can
offer some enlightenment or advice. Apologies in advance for the long
post but I wanted to include all the relevant information.
I'm using the Java interface for the XML DB. I'm creating some very
simple XML structures to keep track of user profiles. When the profile
gets created, some default 'contexttypes' are automatically inserted.
The users can then specify additional contexttypes as they go along.
These additional types will be appended to the default ones.
The problem I've run into is that as long as no new types are added,
I'm getting back the 5 default types. However as soon as I add 1 new
type and query again, then I only get back that new type, i.e. the
other 5 default types aren't returned.
However when I use the 'dbxml' command line tool, I can see that all 6
types are now in the profile but for some reason, only the last one is
returned. Even when I query in the dbxml tool, I only get back the last
type.
In the following example, for user 1, I've added 2 new types and user 2
still only has all default types:
=============================
</profiles>
<profile>
<userid>1</userid>
....
<contexttypes>
<contexttype>Work</contexttype>
<contexttype>Sport</contexttype>
<contexttype>Study</contexttype>
<contexttype>Fun</contexttype>
<contexttype>Other</contexttype><contexttype>test</contexttype><contexttype>Other</contexttype>
</contexttypes>
</profile><profile>
<userid>2</userid>
....
<contexttypes>
<contexttype>Work</contexttype>
<contexttype>Sport</contexttype>
<contexttype>Study</contexttype>
<contexttype>Fun</contexttype>
<contexttype>Other</contexttype>
</contexttypes>
</profile>
</profiles>
=============================
Queries in 'dbxml' command line tool:
------------------------------------------------
dbxml> query
'collection("test.dbxml")/profiles/profile[userid=2]/contexttypes'
1 objects returned for eager expression
'collection("test.dbxml")/profiles/profile[userid=2]/contexttypes'
dbxml> print
<contexttypes>
<contexttype>Work</contexttype>
<contexttype>Sport</contexttype>
<contexttype>Study</contexttype>
<contexttype>Fun</contexttype>
<contexttype>Other</contexttype>
</contexttypes>
------------------------------------------------
dbxml> query
'collection("test.dbxml")/profiles/profile[userid=2]/contexttypes/contexttype'
5 objects returned for eager expression
'collection("test.dbxml")/profiles/profile[userid=2]/contexttypes/contexttype'
dbxml> print
<contexttype>Work</contexttype>
<contexttype>Sport</contexttype>
<contexttype>Study</contexttype>
<contexttype>Fun</contexttype>
<contexttype>Other</contexttype>
------------------------------------------------
dbxml> query
'collection("test.dbxml")/profiles/profile[userid=1]/contexttypes'
1 objects returned for eager expression
'collection("test.dbxml")/profiles/profile[userid=1]/contexttypes'
dbxml> print
<contexttypes>
<contexttype>Work</contexttype>
<contexttype>Sport</contexttype>
<contexttype>Study</contexttype>
<contexttype>Fun</contexttype>
<contexttype>Other</contexttype><contexttype>test</contexttype><contexttype>Other</contexttype>
</contexttypes>
------------------------------------------------
dbxml> query
'collection("test.dbxml")/profiles/profile[userid=1]/contexttypes/contexttype'
2 objects returned for eager expression
'collection("test.dbxml")/profiles/profile[userid=1]/contexttypes/contexttype'
dbxml> print
<contexttype>test</contexttype>
<contexttype>Other</contexttype>
------------------------------------------------
In the above, why does it only query the last 2 context types? It just
doesn't make sense at all to me.
I hope someone has some ideas. |