Last active
December 28, 2015 08:19
-
-
Save caschwartz/7470708 to your computer and use it in GitHub Desktop.
XQuery - Query to isolate superscript numbers and change to ASCII in the <tei:hi> element for TEI metadata
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/4/13 Query to isolate the superscript numbers and change to ASCII numbers in the <tei:hi> element :) | |
| declare namespace tei = "http://www.tei-c.org/ns/1.0"; | |
| for $doc in fn:collection() | |
| let $superNums := $doc//tei:hi[@rend = "super"] | |
| for $superNum in $superNums | |
| (: Where clause isolates the superscript numbers (since some are already ASCII numbers) :) | |
| where fn:not($superNum castable as xs:integer) | |
| return let $normNum := fn:normalize-unicode($superNum, "NFKC") (: Change superscript numbers to ASCII numbers :) | |
| (: The imperative function to replace the text node for the <tei:hi> element :) | |
| return xdmp:node-replace($superNum/text(), text{ $normNum }) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment