SPFE Documentation | Collections > SPFE Function Reference > get-topic-type-alias-singular

Function: get-topic-type-alias-singular

get-topic-type-alias-singular(topic-set-id as item()*, topic-type-name as item()*, config as item()*) as item()*

Description

Gets the singular version of a topic type alias. Topic types are formally named using their XML namespace URIs. However, if you want to display the name of a topic type publicly, for instance in a list of topics or in the visible metadata of a topic, you will need a human readable name for the topic type: the topic type alias. Topic type aliases are defined in the configuration of a topic type, in the setting /topic-type/aliases. The topic type alias setting associates a singular and plural topic type alias with a topic type namespace URI:

<topic-type>
    <xmlns>http://spfeopentoolkit.org/ns/spfe-docs</xmlns>
    <aliases>
        <singular>Configuration setting</singular>
        <plural>Configuration settings</plural>
    </aliases>
                

The sf:get-topic-type-alias-singular function looks up the singular version of the topic type alias in the configuration and returns it. To get the plural version of the alias, use the sf:get-topic-type-alias-plural.

Return value

Return type: item()*

The singular version of the topic type alias. An error occurs if a matching topic type alias is not found.

Source file

$SPFEOT_HOME/1.0/scripts/common/utility-functions.xsl

Parameters

topic-set-id

Type: item()*

The id of the current topic set.

topic-type-name

Type: item()*

The namespace URI of the topic type. This is the value declared in the xmlns attribute of the topic source file:

<function-and-template-descriptions
    xmlns="http://spfeopentoolkit.org/ns/spfe-docs"                            
                        

It is also the value declared in the target-namespace attribute of the xsd:schema element of the topic type schema:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
	targetNamespace="http://spfeopentoolkit.org/ns/spfe-docs">                            
                        

Note, however, that it is possible for a synthesis stage script to output a topic in a different namespace from the input sources. This may particularly be the case if the synthesis stage is combining content from multiple sources. In this case the namespace of a topic may be different at the presentation stage than it was when it was written. This should not cause a problem as long as namespace aliases are declared for a namespace at the time you call this function.

config

Type: item()*

A pointer to the configuration data. In a standard SPFE XSLT script, this is the variable $config.

Definition

            <xsl:function name="sf:get-topic-type-alias-singular">
		               <xsl:param name="topic-set-id"/>
		               <xsl:param name="topic-type-name"/>
		               <xsl:param name="config"/>
		               <xsl:choose >
			                   <xsl:when test="$config/config:content-set/config:topic-set[config:topic-set-id=$topic-set-id]/config:topic-type[config:name=$topic-type-name]/config:aliases/config:singular">
				                       <xsl:value-of select="$config/config:content-set/config:topic-set[config:topic-set-id=$topic-set-id]/config:topic-type[config:name=$topic-type-name]/config:aliases/config:singular"/>
			                   </xsl:when>
			                   <xsl:otherwise >
				                       <xsl:call-template name="sf:error">
					                           <xsl:with-param name="message">
						                               <xsl:text >No singular topic type alias found for topic type </xsl:text>
						                               <xsl:value-of select="$topic-type-name"/>
						                               <xsl:text >. This setting should be defined in the configuration files at </xsl:text>
						                               <xsl:text >/topic-type/aliases/singular.</xsl:text>
					                           </xsl:with-param>
				                       </xsl:call-template>
				                 
				      <xsl:value-of select="$topic-type-name"/>
			                   </xsl:otherwise>
		               </xsl:choose>
	           </xsl:function>