Description
The functx:format-as-title-en function treats a sequence of strings like titles, moving the words "A", "An" and "The" to the end.
Arguments and Return TypeName | Type | Description |
$titles |
xs:string* |
the titles to format |
return value |
xs:string* |
XQuery Function DeclarationSee XSLT definition. | declare namespace functx = "http://www.functx.com";
declare function functx:format-as-title-en
( $titles as xs:string* ) as xs:string* {
let $wordsToMoveToEnd := ('A', 'An', 'The')
for $title in $titles
let $firstWord := functx:substring-before-match($title,'\W')
return if ($firstWord = $wordsToMoveToEnd)
then replace($title,'(.*?)\W(.*)', '$2, $1')
else $title
} ; |
ExamplesXQuery Example | Results |
---|
functx:format-as-title-en(
('A Midsummer Night''s Dream',
'The Merchant of Venice',
'Hamlet')) |
('Midsummer Night's Dream, A',
'Merchant of Venice, The',
'Hamlet'''Midsummer Night's Dream, A',
'Merchant of Venice, The',
'Hamlet') |
Depends OnSee AlsoHistory |
Recommended Reading:
|