Goal: Generate given element (with a priori known name) but calculated attribute values.
Solution: Use literal result element as usually - and specify att. values in so-called attribute value templates (AVT):
<link ref="odkaz_dovnitr_dok">
...
</link>
<xsl:template match="link">
<a href="#{@ref}"> ... </a>
</xsl:template>
The link will be transformed to element "a", the attribute value "href" will be calculated so that it inserts "#" before the original value of "ref"