The XML representation of multiple reference attributes is as a sequence of reference elements – each one including also the sub-attributes (if any); e.g. something like this:
<gn4:story id="obj41196">
. . .
<gn4:objs nav:handle="1">
<gn4:ref idref="obj41197">
<gn4:title>Sub title</gn4:title>
<gn4:caption>Sub caption</gn4:caption>
<nav:refObject idref="obj41197">
<gn4:image id="obj41197" . . .>
</gn4:image>
</nav:refObject>
</gn4:ref>
. . .
</gn4:objs>
. . .
</gn4:story>
for the assets associated with a story via the ‘objs’ multiple reference attribute. Based on this representation, the query to find all the stories associated with the object with database id 41197 is
gn4:story[gn4:objs/gn4:ref/@idref='obj41197']
The query to find all the stories associated with an image titled ‘Test’ is:
gn4:story[gn4:objs/gn4:ref/nav:refObject/gn4:image/gn4:title='Test']
Sub-attributes can be used as well, so
gn4:story[gn4:objs/gn4:ref/gn4:caption='Sub caption']
returns all stories with an associated object caption ‘Sub caption’. Conditions on sub-attributes and referenced objects can be combined of course, for example
gn4:story[gn4:objs/gn4:ref[@idref='obj41197' and contains(gn4:caption,'Israel')]]
returns all stories associated with the object with database id 41197 with a caption containing the word ‘Israel’. Note that this is not the same thing as
gn4:story[gn4:objs/gn4:ref/@idref='obj41197' and
contains(gn4:objs/gn4:ref/gn4:caption,'Israel')]
that returns all stories that are associated object with database id 41197 and that also have an associated object (not necessarily the same one) with a caption containing the word ‘Israel’.
The same ‘nav:referencing’ representation is available for multiple reference objects, so the query
gn4:image[nav:referencing/nav:referencingBy[@attrName='story.objs']
/nav:refs/nav:refObject]
returns all images associated to at least one story, and
gn4:image[nav:referencing/nav:referencingBy[@attrName='story.objs']
/nav:refs/nav:refObject/@idref = 'obj41196']
returns all images associated with the story with database id 41196.