Last active
October 13, 2015 00:57
-
-
Save caschwartz/4113606 to your computer and use it in GitHub Desktop.
XQuery - Query removes final period from names unless part of name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| xquery version "1.0-ml"; | |
| (: 11/16/12 This query removes the final period from names :) | |
| declare namespace ia = "http://my.local.namespace.name"; | |
| let $docs := xdmp:directory("/ia-xml/i/", "infinity") | |
| let $meta := $docs/ia:doc/ia:metadata | |
| for $name in $meta/ia:name | |
| let $newNameNode := if (fn:matches($name, "[a-zA-Z]\.\s*$")) then (: keeps final period for names with initials, titles, etc. :) | |
| () | |
| else if (fn:matches($name, "\.\s*$")) then | |
| <name xmlns="http://my.local.namespace.name">{ fn:normalize-space(fn:replace($name, "\.\s*$", "")) }</name> | |
| else () | |
| where fn:not($name = "") | |
| order by $newNameNode | |
| return (xdmp:set-request-time-limit(3600), xdmp:node-replace($name, $newNameNode)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment