|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
|
xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
|
xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
|
|
xmlns:f="http://www.oxygenxml.com/xsl/functions"
|
|
exclude-result-prefixes="xs xd f"
|
|
version="2.0">
|
|
|
|
<xsl:param name="matchElement" as="xs:string*" select="'topic'"/>
|
|
|
|
<xd:doc>
|
|
<xd:desc>Verifies if the current node is a topic(or specialization).</xd:desc>
|
|
<xd:param name="node">Current node to check.</xd:param>
|
|
</xd:doc>
|
|
<xsl:function name="f:match4extraction" as="xs:boolean">
|
|
<xsl:param name="node" as="node()"/>
|
|
<xsl:value-of select="local-name($node) = $matchElement"/>
|
|
</xsl:function>
|
|
|
|
<xd:doc>
|
|
<xd:desc>Generate a file name using current node's id.</xd:desc>
|
|
<xd:param name="nodeName">Current node.</xd:param>
|
|
<xd:param name="titleVal">Title of current node.</xd:param>
|
|
|
|
<xd:return>Unique file name generated from current node title.</xd:return>
|
|
</xd:doc>
|
|
<xsl:function name="f:use-title">
|
|
<xsl:param name="nodeName" as="node()"></xsl:param>
|
|
<xsl:param name="titleVal" as="xs:string"></xsl:param>
|
|
<xsl:variable name="uniqueAddon">
|
|
<xsl:if test="$nodeName/preceding-sibling::node()[f:match4extraction($nodeName)][normalize-space(xs:string(title)) = normalize-space(xs:string($titleVal))]">
|
|
<xsl:value-of select="'42'"/>
|
|
</xsl:if>
|
|
</xsl:variable>
|
|
<xsl:value-of select="concat(replace(lower-case(normalize-space(xs:string($titleVal))), ' ', '_'), $uniqueAddon)"/>
|
|
</xsl:function>
|
|
|
|
|
|
</xsl:stylesheet>
|