XQuery for Pig Latin
The example shows a progression of XQuery 3.0 scripts that implement Pig Latin translation, starting from a single hardcoded word and evolving to handle full sentences with punctuation. It demonstrates functional recursion and string manipulation using core XQuery functions like `fn:substring`, `fn:replace`, `fn:string-to-codepoints`, `fn:tokenize`, and `fn:string-join`. The final version declares custom functions `local:move-letters`, `local:parse-word`, and `local:parse-sentence` to process the phrase "Will you adjust the thermometer?" into its Pig Latin equivalent, preserving sentence structure. The code highlights XQuery's ability to handle text transformation without external libraries, relying solely on its built-in string and sequence operations.
AI-generated description