Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify the raipi:prepare-record function in the registers.xqm module #225

Open
daliboris opened this issue Apr 16, 2024 · 0 comments
Open

Comments

@daliboris
Copy link
Contributor

daliboris commented Apr 16, 2024

The raipi:prepare-record function contains typeswitch with identical code in two case clauses, maybe we can simplify it:

let $elements-to-change := ("person", "place") 
(: note:  read names from the configuration, perhaps $config:register-map? :)

let $element-name := if($node instance of element()) then local-name($node) else ()

return if($element-name = $elements-to-change) then
    element {node-name($node)} {
                (: copy attributes :)
                for $att in $node/@* except ($node/@xml:id, $node/@resp, $node/@when)
                return
                    $att
                ,
                attribute xml:id {$id}
                ,
                attribute when {format-date(current-date(), '[Y]-[M,2]-[D,2]')}
                ,
                attribute resp {$resp}
                ,
                for $child in $node/node()
                return $child
            }
    else
        $node

Or you can keep typeswitch expression and modify case clauses like this (see here):

case element(tei:person) | element(tei:place)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant