IT Inventory dashboards

There are many computers in an IT inventory. Each one has a name and textual properties with limited possible values (OS version, disk type,...).

The Data Worker is an HTTP server which receives properties from each computer and generates dashboards for the IT manager. There is a dashboard for each property. A dashboard is rendered as an HTML table where computer names are grouped per values for the corresponding property. While, for example, migrating for one OS version to another, the OS dashboard explicitly lists which computers are still to be migrated.

declare namespace output="";
declare option output:indent "yes";
processing-instruction xml-stylesheet {'href="xsl/xsltforms.xsl" type="text/xsl"'},
let $doc := fn:doc('../private/inventory.xml')/inventory
let $m := $doc/computers/computer
let $nicm := map {
  for $n in $doc/nics/nic
  return entry {fn:data($n/@idref-to-nic-owner)} {fn:data($n/timestamp)}
let $m2 := (
  for $s in $m
  order by $s/name
  return $s
let $totalPC := fn:count($m)
  <html xmlns=""
      <title>R&eacute;partition Postes</title>
        body {{
          font-family: arial,sans-serif;
          font-size: 80%;
        table {{
          border-collapse: collapse;
        table, th, td {{
          border: 1px solid black;
          <inventory xmlns="" total="{$totalPC}" selected="version">{
            ('version', 'architecture', 'model', 'disktype', 'office') ! 
              <group name="{.}">
                let $n := .
                for $s in $m2
                group by $v := (if ($s/*[name() eq $n])
                               then $s/*[name() eq $n]
                               else ' ')
                order by $v
                  <item name="{if ($v eq ' ') then 'unknown' else $v}"
                    $s ! name ! xs:string(.)
          '[h01]:[m01]:[s01] [D]/[M]/[Y,2-2]') || ' - ' || $totalPC ||
          ' ordinateurs dans l''inventaire'
      <xf:select1 ref="@selected">
        <xf:itemset ref="../group">
          <xf:label ref="@name"/>
          <xf:value ref="@name"/>
          <xf:repeat ref="group[@name = /inventory/@selected]/item">
              <td><xf:output value="if(@name = 'unknown', 'inconnu', @name)"/></td>
              <td><xf:output value="@total"/></td>
              <td><xf:output value="."/></td>