Each object in a system belongs to its specific object type, but it can be also considered belonging to the ancestors of its object type. For example the object type ‘story’ derives from the object type ‘package’ that in turn derives from ‘archiveObject’ and so on; this mean that a story object can be also considered a package or an archiveObject (and so on).
GNQuery accommodates this placing the same object multiple times in the virtual XML – once for each of its possible object types:
. . .
<gn4:story id="obj33478" nav:objectType="story" . . .>
<gn4:title>From mobile 2</gn4:title>
. . .
</gn4:story>
<gn4:package id="obj33478" nav:objectType="story" . . .>
<gn4:title>From mobile 2</gn4:title>
. . .
</gn4:package>
<gn4:archiveObject id="obj33478" nav:objectType="story" . . .>
<gn4:title>From mobile 2</gn4:title>
. . .
</gn4:archiveObject>
. . .
in this way the query expression
gn4:archiveObject
returns ALL possible archive objects in the system – including all the stories, as well as packages, images and all other object of types derived (directly or indirectly) from ‘archiveObject’.
Use the XML attribute ‘nav:objectType’ to test for the real type of an object, for example the query expression:
gn4:archiveObject[@nav:objectType='story']
returns all the archive objects that are actually stories – i.e. it is the same thing as:
gn4:story
(This can be useful when writing code that generates query expressions dynamically appending conditions to a common root condition).