help3xsl/online_transform.xsl |   73 +++++++++++++++++++++++-------------------
 1 file changed, 41 insertions(+), 32 deletions(-)

New commits:
commit b48ace599e8c109c4090c178823c6718f78103da
Author:     Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
AuthorDate: Mon Jun 20 21:36:02 2022 +0200
Commit:     Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
CommitDate: Tue Jun 21 11:48:12 2022 +0200

    make generated help files deterministic/reproducible
    
    generate-id() is only stable within a single invocation, the results
    vary from run to run, causing two builds of the same codebase result in
    different output.
    Due to help including snippets from different files, a simple count
    won't be unique enough, but combining it with the sourcefile's topic-ID
    does the trick.
    
    Change-Id: I2ab8988bc34c9136fcd99d074cf0b189a8f40eb7
    Reviewed-on: https://gerrit.libreoffice.org/c/help/+/136197
    Tested-by: Jenkins
    Reviewed-by: Olivier Hallot <olivier.hal...@libreoffice.org>

diff --git a/help3xsl/online_transform.xsl b/help3xsl/online_transform.xsl
index efce9b608..3d6ba7387 100644
--- a/help3xsl/online_transform.xsl
+++ b/help3xsl/online_transform.xsl
@@ -659,16 +659,17 @@
 
 <!-- SWITCH -->
 <xsl:template match="switch">
+    <xsl:variable name="idsw">
+        <xsl:value-of select="//meta/topic/@id" /><xsl:number level="any" 
count="switch|switchinline" format="_1"/>
+    </xsl:variable>
     <xsl:choose>
         <xsl:when test ="@select = 'sys'">
-            <xsl:variable name="idsw" 
select="concat('swlnsys',generate-id())"/>
-            <span id="{$idsw}" class="switch">
+            <span id="swlnsys{$idsw}" class="switch">
                 <xsl:apply-templates />
             </span>
         </xsl:when>
         <xsl:when test ="@select = 'appl'">
-            <xsl:variable name="idsw" 
select="concat('swlnappl',generate-id())"/>
-            <span id="{$idsw}" class="switch">
+            <span id="swlnappl{$idsw}" class="switch">
                 <xsl:apply-templates />
             </span>
         </xsl:when>
@@ -678,16 +679,17 @@
     </xsl:choose>
 </xsl:template>
 <xsl:template match="switch" mode="embedded">
+    <xsl:variable name="idsw">
+        <xsl:value-of select="//meta/topic/@id" /><xsl:number level="any" 
count="switch|switchinline" format="_1"/>
+    </xsl:variable>
     <xsl:choose>
         <xsl:when test ="@select = 'sys'">
-            <xsl:variable name="idsw" 
select="concat('swlnsys',generate-id())"/>
-            <span id="{$idsw}" class="switch">
+            <span id="swlnsys{$idsw}" class="switch">
                 <xsl:apply-templates mode="embedded"/>
             </span>
         </xsl:when>
         <xsl:when test ="@select = 'appl'">
-            <xsl:variable name="idsw" 
select="concat('swlnappl',generate-id())"/>
-            <span id="{$idsw}" class="switch">
+            <span id="swlnappl{$idsw}" class="switch">
                 <xsl:apply-templates mode="embedded"/>
             </span>
         </xsl:when>
@@ -699,16 +701,17 @@
 
 <!-- SWITCHINLINE -->
 <xsl:template match="switchinline">
+    <xsl:variable name="idsw">
+        <xsl:value-of select="//meta/topic/@id" /><xsl:number level="any" 
count="switch|switchinline" format="_1"/>
+    </xsl:variable>
     <xsl:choose>
         <xsl:when test ="@select = 'sys'">
-            <xsl:variable name="idsw" 
select="concat('swlnsys',generate-id())"/>
-            <span id="{$idsw}" class="switchinline">
+            <span id="swlnsys{$idsw}" class="switchinline">
                 <xsl:apply-templates />
             </span>
         </xsl:when>
         <xsl:when test ="@select = 'appl'">
-            <xsl:variable name="idsw" 
select="concat('swlnappl',generate-id())"/>
-            <span id="{$idsw}" class="switchinline">
+            <span id="swlnappl{$idsw}" class="switchinline">
                 <xsl:apply-templates />
             </span>
         </xsl:when>
@@ -718,16 +721,17 @@
     </xsl:choose>
 </xsl:template>
 <xsl:template match="switchinline" mode="embedded">
+    <xsl:variable name="idsw">
+        <xsl:value-of select="//meta/topic/@id" /><xsl:number level="any" 
count="switch|switchinline" format="_1"/>
+    </xsl:variable>
     <xsl:choose>
         <xsl:when test ="@select = 'sys'">
-            <xsl:variable name="idsw" 
select="concat('swlnsys',generate-id())"/>
-            <span id="{$idsw}" class="switchinline">
+            <span id="swlnsys{$idsw}" class="switchinline">
                 <xsl:apply-templates mode="embedded"/>
             </span>
         </xsl:when>
         <xsl:when test ="@select = 'appl'">
-            <xsl:variable name="idsw" 
select="concat('swlnappl',generate-id())"/>
-            <span id="{$idsw}" class="switchinline">
+            <span id="swln{@select}_{$idsw}" class="switchinline">
                 <xsl:apply-templates mode="embedded"/>
             </span>
         </xsl:when>
@@ -1101,13 +1105,15 @@
 <!-- Evaluate a case or caseinline switch -->
 <xsl:template name="insertcase">
     <xsl:param name="embedded" />
-    <xsl:variable name="auxID" select="concat(@select,generate-id())"/>
+    <xsl:variable name="auxID">
+        <xsl:value-of select="//meta/topic/@id" /><xsl:number level="any" 
count="switch|switchinline" format="_1"/>
+    </xsl:variable>
     <xsl:choose>
         <xsl:when test="$embedded = 'yes'">
-            <span hidden="true" id="{$auxID}" 
class="{@select}"><xsl:apply-templates mode="embedded"/></span>
+            <span hidden="true" id="{@select}{$auxID}" 
class="{@select}"><xsl:apply-templates mode="embedded"/></span>
         </xsl:when>
         <xsl:otherwise>
-            <span hidden="true" id="{$auxID}" 
class="{@select}"><xsl:apply-templates/></span>
+            <span hidden="true" id="{@select}{$auxID}" 
class="{@select}"><xsl:apply-templates/></span>
         </xsl:otherwise>
     </xsl:choose>
 </xsl:template>
@@ -1115,26 +1121,27 @@
 <!-- Evaluate a default or defaultinline switch -->
 <xsl:template name="insertdefault">
     <xsl:param name="embedded" />
+    <xsl:variable name="auxID">
+        <xsl:value-of select="//meta/topic/@id" /><xsl:number level="any" 
count="switch|switchinline" format="_1"/>
+    </xsl:variable>
     <xsl:choose>
         <xsl:when test="parent::switch[@select='sys'] or 
parent::switchinline[@select='sys']">
-            <xsl:variable name="auxID" 
select="concat('default',generate-id())"/>
             <xsl:choose>
                 <xsl:when test="$embedded = 'yes'">
-                    <span hidden="true" id="{$auxID}"><xsl:apply-templates 
mode="embedded"/></span>
+                    <span hidden="true" 
id="default{$auxID}"><xsl:apply-templates mode="embedded"/></span>
                 </xsl:when>
                 <xsl:otherwise>
-                    <span hidden="true" id="{$auxID}"><xsl:apply-templates 
/></span>
+                    <span hidden="true" 
id="default{$auxID}"><xsl:apply-templates /></span>
                 </xsl:otherwise>
             </xsl:choose>
         </xsl:when>
         <xsl:when test="parent::switch[@select='appl'] or 
parent::switchinline[@select='appl']">
-            <xsl:variable name="auxID" 
select="concat('default',generate-id())"/>
             <xsl:choose>
                 <xsl:when test="$embedded = 'yes'">
-                    <span hidden="true" id="{$auxID}"><xsl:apply-templates 
mode="embedded"/></span>
+                    <span hidden="true" 
id="default{$auxID}"><xsl:apply-templates mode="embedded"/></span>
                 </xsl:when>
                 <xsl:otherwise>
-                    <span hidden="true" id="{$auxID}"><xsl:apply-templates 
/></span>
+                    <span hidden="true" 
id="default{$auxID}"><xsl:apply-templates /></span>
                 </xsl:otherwise>
             </xsl:choose>
         </xsl:when>
@@ -1270,6 +1277,9 @@
 
 <!-- Insert an object -->
 <xsl:template name="insertobject">
+    <xsl:variable name="auxID">
+        <xsl:value-of select="//meta/topic/@id" /><xsl:number level="any" 
count="object" format="_1"/>
+    </xsl:variable>
     <xsl:variable name="tmp_href"><xsl:value-of 
select="concat($urlpre,'text/shared/00/00000004.xhp')"/></xsl:variable>
     <xsl:variable name="tmp_doc" select="document($tmp_href)"/>
     <xsl:variable name="data">
@@ -1282,7 +1292,6 @@
     <xsl:variable name="height">
         <xsl:call-template name="convert2px"><xsl:with-param name="value" 
select="@height"/></xsl:call-template>
     </xsl:variable>
-    <xsl:variable name="auxID" select="concat('obj',generate-id())"/>
     <xsl:choose>
         <xsl:when test="starts-with(@type,'video/youtube')">
             <div id="{@id}" class="youtube_placeholder">
@@ -1310,7 +1319,7 @@
                     <xsl:with-param name="string" select="@data"/>
                 </xsl:call-template>
             </xsl:variable>
-            <div class="samplefilesection" id="{$auxID}">
+            <div class="samplefilesection" id="obj{$auxID}">
             <h3><xsl:apply-templates 
select="$tmp_doc//variable[@id='samplefile']"/></h3>
             <a class="objectfiles" href="{$src}"><img 
src="media/navigation/libo-calc.svg" width="25px" height="30px"></img></a>
             </div>
@@ -1321,7 +1330,7 @@
                     <xsl:with-param name="string" select="@data"/>
                 </xsl:call-template>
             </xsl:variable>
-            <div class="samplefilesection" id="{$auxID}">
+            <div class="samplefilesection" id="obj{$auxID}">
             <h3><xsl:apply-templates 
select="$tmp_doc//variable[@id='samplefile']"/></h3>
             <a class="objectfiles" href="{$src}"><img 
src="media/navigation/libo-writer.svg" width="25px" height="30px"></img></a>
             </div>
@@ -1332,7 +1341,7 @@
                     <xsl:with-param name="string" select="@data"/>
                 </xsl:call-template>
             </xsl:variable>
-            <div class="samplefilesection" id="{$auxID}">
+            <div class="samplefilesection" id="obj{$auxID}">
             <h3><xsl:apply-templates 
select="$tmp_doc//variable[@id='samplefile']"/></h3>
             <a class="objectfiles" href="{$src}"><img 
src="media/navigation/libo-impress.svg" width="25px" height="30px"></img></a>
             </div>
@@ -1343,7 +1352,7 @@
                     <xsl:with-param name="string" select="@data"/>
                 </xsl:call-template>
             </xsl:variable>
-            <div class="samplefilesection" id="{$auxID}">
+            <div class="samplefilesection" id="obj{$auxID}">
             <h3><xsl:apply-templates 
select="$tmp_doc//variable[@id='samplefile']"/></h3>
             <a class="objectfiles" href="{$src}"><img 
src="media/navigation/libo-draw.svg" width="25px" height="30px"></img></a>
             </div>
@@ -1354,7 +1363,7 @@
                     <xsl:with-param name="string" select="@data"/>
                 </xsl:call-template>
             </xsl:variable>
-            <div class="samplefilesection" id="{$auxID}">
+            <div class="samplefilesection" id="obj{$auxID}">
             <h3><xsl:apply-templates 
select="$tmp_doc//variable[@id='samplefile']"/></h3>
             <a class="objectfiles" href="{$src}"><img 
src="media/navigation/libo-math.svg" width="25px" height="30px"></img></a>
             </div>
@@ -1365,7 +1374,7 @@
                     <xsl:with-param name="string" select="@data"/>
                 </xsl:call-template>
             </xsl:variable>
-            <div class="samplefilesection" id="{$auxID}">
+            <div class="samplefilesection" id="obj{$auxID}">
             <h3><xsl:apply-templates 
select="$tmp_doc//variable[@id='samplefile']"/></h3>
             <a class="objectfiles" href="{$src}"><img 
src="media/navigation/libo-base.svg" width="25px" height="30px"></img></a>
             </div>

Reply via email to