examples/xmlpatterns/qobjectxmlmodel/queries/statisticsInHTML.xq
changeset 0 1918ee327afb
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 <html>
       
     2   <head>
       
     3     <title></title>
       
     4   </head>
       
     5   <body>
       
     6     <p>In total the tree has {count($root//QObject)} QObject instances.</p>
       
     7     <p>Order by occurrence, the QObjects are:</p>
       
     8 
       
     9     <ol>
       
    10     {
       
    11       for $i in $root/preceding-sibling::metaObjects/metaObject
       
    12       let $count := count($root//QObject[@className eq $i/@className])
       
    13       stable order by $count descending
       
    14       return if($count > 1)
       
    15              then <li>{string($i/@className), $count} occurrences</li>
       
    16              else ()
       
    17     }
       
    18     </ol>
       
    19 
       
    20     <h1>Properties</h1>
       
    21     {
       
    22       (: For each QObject, we create a table listing
       
    23        : the properties of that object. :)
       
    24       for $object in $root//QObject
       
    25         return (<h2>{let $name := string($object/@objectName)
       
    26                      return if(string-length($name))
       
    27                             then $name
       
    28                             else "[no name]",
       
    29                      '(', string($object/@className), ')'}</h2>,
       
    30                 <table border="1">
       
    31                   <thead>
       
    32                     <tr>
       
    33                       <td>Property Name</td>
       
    34                       <td>Value</td>
       
    35                     </tr>
       
    36                   </thead>
       
    37                   <tbody>
       
    38                   {
       
    39                     $object/@*/<tr>
       
    40                                  <td>
       
    41                                  {
       
    42                                    name()
       
    43                                  }
       
    44                                  </td>
       
    45                                  <td>
       
    46                                  {
       
    47                                    if(data(.))
       
    48                                    then string(.)
       
    49                                    else "N/A"
       
    50                                  }
       
    51                                  </td>
       
    52                                </tr>
       
    53                   }
       
    54                   </tbody>
       
    55                 </table>)
       
    56     }
       
    57   </body>
       
    58 </html>