From 7f916a003ca68452efef58af85e839cef7f40e67 Mon Sep 17 00:00:00 2001
From: Martin Goik <goik@hdm-stuttgart.de>
Date: Sat, 6 May 2017 17:27:33 +0200
Subject: [PATCH] ing docbook's own profile support

---
 ws/Docbook/.gitignore                         |   2 +-
 .../{positioning.css => positioning.supp.css} |   0
 ws/Docbook/Extensions/Tdata/Makefile          |  23 +-
 ws/Docbook/Preprocess/Xsl/docbook2docbook.xsl |  14 +-
 ws/Docbook/Preprocess/Xsl/docbook2html.xsl    |   2 +-
 .../Preprocess/Xsl/docbookExtractFig.xsl      | 201 ++++++++++--------
 ws/Docbook/Preprocess/make.image              |   2 +-
 7 files changed, 135 insertions(+), 109 deletions(-)
 rename ws/Docbook/CustomLayer/webhelp/common/css/{positioning.css => positioning.supp.css} (100%)

diff --git a/ws/Docbook/.gitignore b/ws/Docbook/.gitignore
index 595ddb800..48941d326 100644
--- a/ws/Docbook/.gitignore
+++ b/ws/Docbook/.gitignore
@@ -1 +1 @@
-docbook-xsl-ns-1.79.0
+docbook-xsl-1.79.2
diff --git a/ws/Docbook/CustomLayer/webhelp/common/css/positioning.css b/ws/Docbook/CustomLayer/webhelp/common/css/positioning.supp.css
similarity index 100%
rename from ws/Docbook/CustomLayer/webhelp/common/css/positioning.css
rename to ws/Docbook/CustomLayer/webhelp/common/css/positioning.supp.css
diff --git a/ws/Docbook/Extensions/Tdata/Makefile b/ws/Docbook/Extensions/Tdata/Makefile
index 6cfba9554..5064f07de 100644
--- a/ws/Docbook/Extensions/Tdata/Makefile
+++ b/ws/Docbook/Extensions/Tdata/Makefile
@@ -66,17 +66,17 @@ ${BUILDROOT_SRC}/${SCRIPTBASENAME}_print.xml \
 ${BUILDROOT_SRC}/${SCRIPTBASENAME}_html.xml \
 ${BUILDROOT_SRC}/${SCRIPTBASENAME}.xml: ${SCRIPTBASENAME}.xml
 	mkdir -p ${BUILDROOT_SRC};  ln -sf /usr/share/hdmwebhelp/extern ${BUILDROOT}
-	${SAXONCMD} -s:${SCRIPTBASENAME}.xml \
-           -xsl:${DBOOK_XSL_PREPROCESS}/Xsl/docbook2docbook.xsl >  ${BUILDROOT_SRC}/${SCRIPTBASENAME}.xml
-	${SAXONCMD} -s:${BUILDROOT_SRC}/${SCRIPTBASENAME}.xml \
-          -xsl:${DBOOK_XSL_PREPROCESS}/Xsl/docbook2html.xsl >  ${BUILDROOT_SRC}/${SCRIPTBASENAME}_html.xml
+	 ${SAXONCMD} -s:$< \
+            -xsl:${DBOOK_XSL_PREPROCESS}/Xsl/docbook2docbook.xsl >  ${BUILDROOT_SRC}/${SCRIPTBASENAME}.xml
+
 	${SAXONCMD} -s:${BUILDROOT_SRC}/${SCRIPTBASENAME}.xml \
-           -xsl:${DBOOK_XSL_PREPROCESS}/Xsl/docbook2print.xsl >  ${BUILDROOT_SRC}/${SCRIPTBASENAME}_print.xml
+           -xsl:${DBOOK_XSL_PREPROCESS}/Xsl/docbook2html.xsl >  ${BUILDROOT_SRC}/${SCRIPTBASENAME}_html.xml
+	 ${SAXONCMD} -s:${BUILDROOT_SRC}/${SCRIPTBASENAME}.xml \
+            -xsl:${DBOOK_XSL_PREPROCESS}/Xsl/docbook2print.xsl >  ${BUILDROOT_SRC}/${SCRIPTBASENAME}_print.xml
 	cd ${BUILDROOT_SRC}; ${SAXONCMD} -s:${SCRIPTBASENAME}.xml -xsl:${DBOOK_XSL_PREPROCESS}/Xsl/docbookExtractFig.xsl
-	mkdir -p ${BUILDROOT_SRC}/_Resources; tar cv- `find . -name Ref -and -type d|grep -v ^\./target`|tar -x -C ${BUILDROOT_SRC}/_Resources
+	mkdir -p ${BUILDROOT_SRC}/Resources; tar cv- `find . -name Ref -and -type d|grep -v ^\./target`|tar -x -C ${BUILDROOT_SRC}/Resources
 	cp ${DBOOK_XSL_PREPROCESS}/make.image  ${BUILDROOT_SRC}
-	cd  ${BUILDROOT_SRC}; $(MAKE) -f make.image
-#	cd  ${BUILDROOT_SRC}; $(MAKE) -j ${numCores} -f make.image
+	cd  ${BUILDROOT_SRC}/Resources; $(MAKE) -f ../make.image
 
 epub: ${BUILDROOT_SRC}/${SCRIPTBASENAME}_html.xml
 	java -cp "/usr/share/java/saxon.jar:/usr/share/java/xslthl-2.1.3.jar" \
@@ -92,10 +92,11 @@ webhelp:${BUILDROOT_SRC}/${SCRIPTBASENAME}_html.xml
 	java -cp "/usr/share/java/saxon.jar:/usr/share/java/xslthl-2.1.3.jar" \
           '-Dxslthl.config=file://${DBOOK_XSL}/highlighting/xslthl-config.xml' \
           com.icl.saxon.StyleSheet \
-          ${BUILDROOT_SRC}/${SCRIPTBASENAME}_html.xml ${DBOOK_XSL_CUSTOM}/webhelp/webhelpHdm.xsl ${dbookXslWebhelpParam}
-	ln -sf ../src/_Resources ${BUILDROOT_WEBHELP}
+            ${BUILDROOT_SRC}/${SCRIPTBASENAME}_html.xml ${DBOOK_XSL_CUSTOM}/webhelp/webhelpHdm.xsl keep.relative.image.uris=0 ${dbookXslWebhelpParam}
+#          ${BUILDROOT_SRC}/${SCRIPTBASENAME}_html.xml ${DBOOK_XSL}/webhelp/xsl/webhelp.xsl keep.relative.image.uris=0 
+	cd ${BUILDROOT_SRC}/Resources; rsync -av * ${DIR}/${BUILDROOT_WEBHELP}
 	cp -r ${DBOOK_XSL}/webhelp/template/* ${BUILDROOT_WEBHELP}     # Images, Css
-	cp -r ${DBOOK_XSL_CUSTOM}/webhelp/common ${BUILDROOT_WEBHELP} 					# Possibly overriding previous
+	cat ${DBOOK_XSL_CUSTOM}/webhelp/common/css/positioning.supp.css >> ${BUILDROOT_WEBHELP}/common/css/positioning.css  # highlighting supplements
 	cd ${DBOOK_XSL}/webhelp/template/search; \
           cp nwSearchFnt.js default.props punctuation.props en-us.props stemmers/en_stemmer.js \
           ${DIR}/${BUILDROOT_WEBHELP}/search
diff --git a/ws/Docbook/Preprocess/Xsl/docbook2docbook.xsl b/ws/Docbook/Preprocess/Xsl/docbook2docbook.xsl
index 0b92d1a7a..d1f42beaf 100644
--- a/ws/Docbook/Preprocess/Xsl/docbook2docbook.xsl
+++ b/ws/Docbook/Preprocess/Xsl/docbook2docbook.xsl
@@ -3,6 +3,8 @@
     xmlns:xlink="http://www.w3.org/1999/xlink"
     xmlns="http://docbook.org/ns/docbook" xmlns:db="http://docbook.org/ns/docbook">
     
+    
+    <xsl:import href="../../docbook-xsl/profiling/profile.xsl"/>
     <xsl:include href="common.xsl"/>
     
     <xsl:param name="generateIdPrefix">__sdwordm4342cs__</xsl:param>
@@ -10,17 +12,20 @@
     <xsl:param name="lastAnswerId" select="document('lastAnswerId.xml',/)/lastAnswer/@id" />
     
     
+    
+    
     <xsl:key name="internRef" match="//*[@linkend]" use="@linkend"/>
     
-    <xsl:template match="@* | node()">
+<!--  <xsl:template match="node() | @*">
         <xsl:copy>
-            <xsl:apply-templates select="@*[name(.) != 'xml:base'] | node()"/>
+          <xsl:apply-templates select="node()| @*"/>
         </xsl:copy>
     </xsl:template>
+-->    
     
-    <xsl:template match="@fileref">
+<!--    <xsl:template match="@fileref">
         <xsl:attribute name="fileref">
-            <xsl:text>_Resources/</xsl:text> <!-- account for descend into "target" subdir -->
+            <xsl:text>_Resources/</xsl:text> <!-\- account for descend into "target" subdir -\->
             <xsl:if test="ancestor::*/@xml:base">
                 <xsl:call-template name="hdm.get.leftmost.of.separator">
                     <xsl:with-param name="path" select="ancestor::*/@xml:base"/>
@@ -31,6 +36,7 @@
             <xsl:value-of select="."/>
         </xsl:attribute>
     </xsl:template>
+-->    
     
     <xsl:template match="*" mode="hdmIdGenerate">
         <xsl:choose>
diff --git a/ws/Docbook/Preprocess/Xsl/docbook2html.xsl b/ws/Docbook/Preprocess/Xsl/docbook2html.xsl
index 53793d6f7..770e76499 100644
--- a/ws/Docbook/Preprocess/Xsl/docbook2html.xsl
+++ b/ws/Docbook/Preprocess/Xsl/docbook2html.xsl
@@ -9,7 +9,7 @@
     
     <xsl:template match="@* | node()">
         <xsl:copy>
-            <xsl:apply-templates select="@*[name(.) != 'xml:base'] | node()"/>
+          <xsl:apply-templates select="node()| @*"/>
         </xsl:copy>
     </xsl:template>
     
diff --git a/ws/Docbook/Preprocess/Xsl/docbookExtractFig.xsl b/ws/Docbook/Preprocess/Xsl/docbookExtractFig.xsl
index 5f0fcdd23..75d9529e0 100644
--- a/ws/Docbook/Preprocess/Xsl/docbookExtractFig.xsl
+++ b/ws/Docbook/Preprocess/Xsl/docbookExtractFig.xsl
@@ -1,100 +1,119 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
-    xmlns:xlink="http://www.w3.org/1999/xlink"
-    xmlns="http://docbook.org/ns/docbook" xmlns:d="http://docbook.org/ns/docbook">
-    
-    <xsl:include href="common.xsl"/>
+  xmlns:xlink="http://www.w3.org/1999/xlink"
+  xmlns="http://docbook.org/ns/docbook" xmlns:d="http://docbook.org/ns/docbook">
   
-    <xsl:template match="/">
-      
-      <xsl:variable name="figFiles" select="//d:imagedata[ends-with(@fileref, '.fig') ]" />
-      
-        <xsl:apply-templates select="//d:imagedata[ends-with(@fileref, '.fig') ]" mode="printLatex"/>
-      
-      <xsl:result-document method="text" encoding="utf-8" href="_Resources/_mediaobjects.list" >
-        <xsl:text>all: </xsl:text>
-
-        <xsl:for-each select="$figFiles">
-          <xsl:value-of select="@fileref"/>
-          <xsl:text>.pdf </xsl:text>
-        </xsl:for-each>
-        
-        <xsl:for-each select="//d:videodata[ends-with(@fileref, '.webm') ]">
-          <xsl:value-of select="@fileref"/>
-          <xsl:text>.mp4 </xsl:text>
-        </xsl:for-each>
-        
-      </xsl:result-document>
-    </xsl:template>
+  
+  <xsl:import href="../../docbook-xsl/xhtml/chunk.xsl"/>
+  
+  <xsl:include href="common.xsl"/>
+  
+  <xsl:template match="/">
     
-  <xsl:template match="d:imagedata" mode="printLatex">
-        <xsl:variable name="fullFileName" select="@fileref"/>
-        <xsl:variable name="dirPath">
-            <xsl:call-template name="hdm.get.leftmost.of.separator">
-                <xsl:with-param name="path" select="$fullFileName"/>
-                <xsl:with-param name="separator" select="'/'"/>
-            </xsl:call-template>
-        </xsl:variable>
-        
-        <xsl:variable name="fileName">
-            <xsl:call-template name="hdm.get.pure.filename">
-                <xsl:with-param name="path" select="$fullFileName"/>
-            </xsl:call-template>
-        </xsl:variable>
-        
-        <xsl:variable name="fileBaseName">
-            <xsl:call-template name="hdm.get.leftmost.of.separator">
-                <xsl:with-param name="path" select="$fileName"/>
-                <xsl:with-param name="separator" select="'.'"/>
+    <xsl:variable name="figFiles" select="//d:imagedata[ends-with(@fileref, '.fig') ]" />
+    
+    <xsl:apply-templates select="//d:imagedata[ends-with(@fileref, '.fig') ]" mode="printLatex"/>
+    
+    <xsl:result-document method="text" encoding="utf-8" href="mediaobjects.list" >
+      <xsl:text>all: </xsl:text>
+      
+      <xsl:for-each select="$figFiles">
+        <xsl:call-template name="relative-uri">
+          <xsl:with-param name="destdir">
+            <xsl:call-template name="dbhtml-dir">
+              <xsl:with-param name="context" select="."/>
             </xsl:call-template>
-        </xsl:variable>
+          </xsl:with-param>
+        </xsl:call-template>
         
-        <xsl:variable name="moduleBaseName">
-            <xsl:call-template name="hdm.get.leftmost.of.separator">
-                <xsl:with-param name="path" select="ancestor::*/@xml:base"/>
-                <xsl:with-param name="separator" select="'/'"/>
+        <xsl:value-of select="@fileref"/>
+        <xsl:text>.pdf </xsl:text>
+      </xsl:for-each>
+      
+      <xsl:for-each select="//d:videodata[ends-with(@fileref, '.webm') ]">
+        <xsl:call-template name="relative-uri">
+          <xsl:with-param name="destdir">
+            <xsl:call-template name="dbhtml-dir">
+              <xsl:with-param name="context" select="."/>
             </xsl:call-template>
-        </xsl:variable>
-        
-        <xsl:variable name="fullGenerateBasename" >
-            <xsl:value-of select="$dirPath"/>
-            <xsl:text>/Generate/</xsl:text>
-            <xsl:value-of select="$fileBaseName"/>
-        </xsl:variable>
-
-
-       <xsl:value-of select="$fullGenerateBasename"/>
-      <xsl:text>.tex
-      </xsl:text>
-        
-      <xsl:result-document method="text" encoding="utf-8" href="{$fullGenerateBasename}.tex" >
-            <xsl:text>\input{/usr/share/hdm-docbook-xsl/Preprocess/pre.tex} 
-\begin{mycenterframe}{</xsl:text>
-<xsl:apply-templates select="." mode="object.title.markup.textonly"/>
-<xsl:text>}
-\multifigure{Generate/</xsl:text>
-<xsl:value-of select="$fileBaseName" />
-<xsl:text>}
-\end{mycenterframe}
-\end{document}
-</xsl:text>
-        </xsl:result-document>
-      </xsl:template>
-        
-    <xsl:template name="hdm.get.pure.filename">
-        <xsl:param name="path"/>
-        <xsl:choose>
-            <xsl:when test="contains($path, '/' )">
-                <xsl:call-template name="hdm.get.pure.filename">
-                    <xsl:with-param name="path">
-                        <xsl:value-of select="substring-after($path, '/')"/>
-                    </xsl:with-param>
-                </xsl:call-template>
-            </xsl:when>
-            <xsl:otherwise>
-                <xsl:value-of select="$path"/>
-            </xsl:otherwise>
-        </xsl:choose>
-    </xsl:template>
+          </xsl:with-param>
+        </xsl:call-template>
+        <xsl:value-of select="@fileref"/>
+        <xsl:text>.mp4 </xsl:text>
+      </xsl:for-each>
+      
+    </xsl:result-document>
+  </xsl:template>
+  
+  <xsl:template match="d:imagedata" mode="printLatex">
+    
+    <xsl:variable name="dirPath">
+      <xsl:call-template name="hdm.get.leftmost.of.separator">
+        <xsl:with-param name="path" select="@fileref"/>
+        <xsl:with-param name="separator" select="'/'"/>
+      </xsl:call-template>
+    </xsl:variable>
     
+    <xsl:variable name="fileName">
+      <xsl:call-template name="hdm.get.pure.filename">
+        <xsl:with-param name="path" select="@fileref"/>
+      </xsl:call-template>
+    </xsl:variable>
+    
+    <xsl:variable name="fileBaseName">
+      <xsl:call-template name="hdm.get.leftmost.of.separator">
+        <xsl:with-param name="path" select="$fileName"/>
+        <xsl:with-param name="separator" select="'.'"/>
+      </xsl:call-template>
+    </xsl:variable>
+    
+    <xsl:variable name="fullGenerateBasename" >
+      <xsl:call-template name="relative-uri">
+        <xsl:with-param name="destdir">
+          <xsl:call-template name="dbhtml-dir">
+            <xsl:with-param name="context" select="."/>
+          </xsl:call-template>
+        </xsl:with-param>
+      </xsl:call-template>
+      <xsl:value-of select="$dirPath"/>
+      <xsl:text>/Generate/</xsl:text>
+      <xsl:value-of select="$fileBaseName"/>
+    </xsl:variable>
+    
+    
+    <xsl:value-of select="$fullGenerateBasename"/>
+    <xsl:text>.tex
+    </xsl:text>
+    
+    <xsl:result-document method="text" encoding="utf-8" href="Resources/{$fullGenerateBasename}.tex" >
+      <xsl:text>\input{/usr/share/hdm-docbook-xsl/Preprocess/pre.tex} 
+        \begin{mycenterframe}{</xsl:text>
+      <xsl:apply-templates select="." mode="object.title.markup.textonly"/>
+      <xsl:text>}
+        \multifigure{Generate/</xsl:text>
+      <xsl:value-of select="$fileBaseName" />
+      <xsl:text>}
+        \end{mycenterframe}
+        \end{document}
+      </xsl:text>
+    </xsl:result-document>
+  </xsl:template>
+  
+  <xsl:template name="hdm.get.pure.filename">
+    <!-- Stripping a filename path from all directory components -->
+    <xsl:param name="path"/>
+    <xsl:choose>
+      <xsl:when test="contains($path, '/' )">
+        <xsl:call-template name="hdm.get.pure.filename">
+          <xsl:with-param name="path">
+            <xsl:value-of select="substring-after($path, '/')"/>
+          </xsl:with-param>
+        </xsl:call-template>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="$path"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+  
 </xsl:stylesheet>
diff --git a/ws/Docbook/Preprocess/make.image b/ws/Docbook/Preprocess/make.image
index 3fb44e65a..24e3e7a2e 100644
--- a/ws/Docbook/Preprocess/make.image
+++ b/ws/Docbook/Preprocess/make.image
@@ -1,4 +1,4 @@
-include _Resources/_mediaobjects.list
+include ../mediaobjects.list
 
 # image and video generating rules
 
-- 
GitLab