flatten #19

Open
opened 2025-10-07 23:27:42 +01:00 by apb · 0 comments
Owner
(:~ 
 :simplify by omitting elements with only one child
:)
declare function xp:flatten($input as element()) as element() {
  if (1=count($input/*)) then xp:flatten($input/*)
  else element {node-name($input) }
      {$input/@*,
       for $child in $input/node()
          return
             if ($child instance of element())
                then xp:flatten($child)
                else $child
      }
};
```xquery (:~ :simplify by omitting elements with only one child :) declare function xp:flatten($input as element()) as element() { if (1=count($input/*)) then xp:flatten($input/*) else element {node-name($input) } {$input/@*, for $child in $input/node() return if ($child instance of element()) then xp:flatten($child) else $child } }; ```
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: quodatum/basex-lsp#19
No description provided.