Find the maximum depth of the document named "partlist.xml"
define function depth(element $e) returns xsd:integer { -- An empty element has depth 1 -- Otherwise, add 1 to max depth of children if empty($e/*) then 1 else max(depth($e/*)) + 1 } depth(document("partlist.xml"))