summaryrefslogtreecommitdiffstats
path: root/examples/xmlpatterns/qobjectxmlmodel/queries
diff options
context:
space:
mode:
Diffstat (limited to 'examples/xmlpatterns/qobjectxmlmodel/queries')
-rw-r--r--examples/xmlpatterns/qobjectxmlmodel/queries/statisticsInHTML.xq58
-rw-r--r--examples/xmlpatterns/qobjectxmlmodel/queries/wholeTree.xq3
2 files changed, 61 insertions, 0 deletions
diff --git a/examples/xmlpatterns/qobjectxmlmodel/queries/statisticsInHTML.xq b/examples/xmlpatterns/qobjectxmlmodel/queries/statisticsInHTML.xq
new file mode 100644
index 0000000..14a7a14
--- /dev/null
+++ b/examples/xmlpatterns/qobjectxmlmodel/queries/statisticsInHTML.xq
@@ -0,0 +1,58 @@
+<html>
+ <head>
+ <title></title>
+ </head>
+ <body>
+ <p>In total the tree has {count($root//QObject)} QObject instances.</p>
+ <p>Order by occurrence, the QObjects are:</p>
+
+ <ol>
+ {
+ for $i in $root/preceding-sibling::metaObjects/metaObject
+ let $count := count($root//QObject[@className eq $i/@className])
+ stable order by $count descending
+ return if($count > 1)
+ then <li>{string($i/@className), $count} occurrences</li>
+ else ()
+ }
+ </ol>
+
+ <h1>Properties</h1>
+ {
+ (: For each QObject, we create a table listing
+ : the properties of that object. :)
+ for $object in $root//QObject
+ return (<h2>{let $name := string($object/@objectName)
+ return if(string-length($name))
+ then $name
+ else "[no name]",
+ '(', string($object/@className), ')'}</h2>,
+ <table border="1">
+ <thead>
+ <tr>
+ <td>Property Name</td>
+ <td>Value</td>
+ </tr>
+ </thead>
+ <tbody>
+ {
+ $object/@*/<tr>
+ <td>
+ {
+ name()
+ }
+ </td>
+ <td>
+ {
+ if(data(.))
+ then string(.)
+ else "N/A"
+ }
+ </td>
+ </tr>
+ }
+ </tbody>
+ </table>)
+ }
+ </body>
+</html>
diff --git a/examples/xmlpatterns/qobjectxmlmodel/queries/wholeTree.xq b/examples/xmlpatterns/qobjectxmlmodel/queries/wholeTree.xq
new file mode 100644
index 0000000..253cd43
--- /dev/null
+++ b/examples/xmlpatterns/qobjectxmlmodel/queries/wholeTree.xq
@@ -0,0 +1,3 @@
+<!-- This is the QObject tree for this application, rendered as XML. -->,
+$root/preceding-sibling::metaObjects,
+$root