SPFE Documentation | Collections > SPFE Function Reference > get-topic-link-priority

Function: get-topic-link-priority

get-topic-link-priority(topic-type-name as item()*, topic-set-id as item()*, config as item()*) as item()*

Description

Gets the link priority of a topic. Link priority is used to determine which topic to link to when more than one topic is identified as a source for a subject. Lower numbers indicate a higher priority.

Link priority is calculated by adding the link priority of the topic type, defined in /topic-type/topic-type-link-priority to the link priority of the topic set, defined in /topic-set/topic-set-link-priority.

Return value

Return type: item()*

The link priority of the topic.

Source file

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

Parameters

topic-type-name

Type: item()*

The name of the topic type, as specified in its configuration file a /topic-type/name. By default, the resolve step places the topic type name of the topic in the type attribute of the ss:topic wrapper element.

<ss:topic type="http://spfeopentoolkit.org/ns/eppo-simple"
    topic-type-alias="Task"
    full-name="http://spfeopentoolkit.org/spfe-docs/topic-types/think-plan-do-topic/adding-a-content-set"
    local-name="adding-a-content-set" title="Adding a new content set"
    excerpt="A content set (content-set) is a collection of one or more related topic sets, each of which can use different schemas. ...">

                        

Since linking is done at the presentation stage, you can read the topic type namespace URI from this attribute for the topic you are processing.

topic-set-id

Type: item()*

The topic-set-id of the topic. The topic-set-id is passed as a parameter to every processing script.

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-link-priority">
		               <xsl:param name="topic-type-name"/>
		               <xsl:param name="topic-set-id"/>
		               <xsl:param name="config"/>

		               <xsl:variable name="topic-type-link-priority" select="$config/config:content-set/config:topic-set[config:topic-set-id eq $topic-set-id]/config:topic-type[config:name eq $topic-type-name]/config:topic-type-link-priority"/>
		               <xsl:if test="count($topic-type-link-priority) gt 1">
                      <xsl:message select="count($topic-type-link-priority), $topic-set-id, $topic-type-name, for $i in $topic-type-link-priority return generate-id($i)"/>
                 </xsl:if>
		               <xsl:variable name="topic-set-link-priority" select="$config/config:content-set/config:topic-set[config:topic-set-id eq $topic-set-id]/config:topic-set-link-priority"/>
		               <xsl:if test="normalize-space($topic-type-link-priority) eq ''">
			                   <xsl:call-template name="sf:error">
				                       <xsl:with-param name="message" select="'Topic type link priority not set for namespace ', $topic-type-name"/>
			                   </xsl:call-template>
		               </xsl:if>
		               <xsl:if test="normalize-space($topic-set-link-priority) eq ''">
			                   <xsl:call-template name="sf:error">
				                       <xsl:with-param name="message" select="'Topic set link priority not set for topic set ID ', $topic-set-id"/>
			                   </xsl:call-template>
		               </xsl:if>
		
		               <xsl:value-of select="$topic-type-link-priority + $topic-set-link-priority"/>
	           </xsl:function>