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* |
XSLT Function DeclarationSee XQuery definition. | <xsl:function name="functx:format-as-title-en" as="xs:string*"
xmlns:functx="http://www.functx.com">
<xsl:param name="titles" as="xs:string*"/>
<xsl:variable name="wordsToMoveToEnd"
select="('A', 'An', 'The')"/>
<xsl:for-each select="$titles">
<xsl:variable name="title" select="."/>
<xsl:variable name="firstWord"
select="functx:substring-before-match($title,'\W')"/>
<xsl:sequence select="if ($firstWord = $wordsToMoveToEnd)
then replace($title,'(.*?)\W(.*)', '$2, $1')
else $title"/>
</xsl:for-each>
</xsl:function>
|
ExamplesXPath 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:
|