Children attributes

Build 1501 on 14/Nov/2017  This topic last edited on: 5/Aug/2014, at 14:15

The XML representation of a children attribute is an XML element named as the attribute directly containing the XML representation of the children objects contained in the attribute; e.g. something like this:

 <article id="obj41143" . . .>

   . . .

  <txts>

      <head id="obj41172"  . . .>

        . . .

      </head>

      <body id="obj41144" . . . >

        . . .

      </body>

    </txts>

   . . .

 </article>

 

for the texts of an article. Based on this XML representation, the query to return all articles with a ‘head’ text is:

 gn4:article[gn4:txts/gn4:head]

Similarly, to find the articles with a ‘head’ text with a specified name use:

 gn4:article[gn4:txts/gn4:head/@name='Copy of New story,hd']

To find all articles containing 8 or more texts use:

 gn4:article[count(gn4:txts/gn4:*)>=8]

and to find all articles with at least 4 photos (‘photoCaption’ texts) use:

 gn4:article[count(gn4:txts/gn4:photoCaption)>=4]

The XML representation of every child object includes ‘nav:referencing/nav:parentBy’ sub-elements listing its parent objects (again, like the standard navigation XML), e.g. for a ‘head’ text:

 <head id="obj41172" . . .>

   . . .

   <nav:referencing>

    <nav:parentBy attrName="article.txts">

        <nav:refs handle="1">

          <nav:refObject idref="obj41143">

            <article id="obj41143" . . . >

              . . .

            </article>

          </nav:refObject>

        </nav:refs>    

      </nav:parentBy>

     . . .

   </nav:referencing>

   . . .

 </head>

Use these elements to create queries based on the parents of an object, for example:

 gn4:txt[not(nav:referencing/nav:parentBy[@attrName='article.txts']

   /nav:refs/nav:refObject)]

returns all ‘txt’ objects that do not have any parent via the attribute ‘article.txts’ – i.e. all texts that are not in an article. This query:

 gn4:txt[nav:referencing/nav:parentBy[@attrName='article.txts']

   /nav:refs/nav:refObject/@idref = 'obj41224']

returns all texts that are in the article with the specified database id (41224), and this one:

 gn4:txt[nav:referencing/nav:parentBy[@attrName='article.txts']

   /nav:refs/nav:refObject/*/@name = 'fashion1']

returns all texts that are in an article named ‘fashion1’ .