Warning, /office/calligra/windows/calligra_installer/PreserveGUIDs.xslt is written in an unsupported language. File is not indexed.

0001 <?xml version="1.0" encoding="utf-8"?>
0002 <!--
0003     Copyright (c) 2011-2012 KO GmbH.  All rights reserved.
0004     Copyright (c) 2011-2012 Stuart Dickson <stuartmd@kogmbh.com>
0005      
0006     The use and distribution terms for this software are covered by the
0007     Common Public License 1.0 (http://opensource.org/licenses/cpl1.0.php)
0008     which can be found in the file CPL.TXT at the root of this distribution.
0009     By using this software in any fashion, you are agreeing to be bound by
0010     the terms of this license.
0011    
0012     You must not remove this notice, or any other, from this software.
0013    
0014     Based on an example from Mark Lines-Davies' blog entry "Preserve GUIDs
0015     in Wix generated by the Heat harvesting tool" at
0016     http://marklinesdavies.blogware.com/blog/_archives/2011/3/14/4771326.html
0017 -->
0018 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
0019         xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"
0020         xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
0021        
0022         <xsl:output method="xml" indent="yes"/>
0023        
0024         <!--Identity Transform-->
0025         <xsl:template match="@*|node()">
0026                 <xsl:copy>
0027                         <xsl:apply-templates select="@*|node()"/>
0028                 </xsl:copy>
0029         </xsl:template>
0030        
0031  
0032     <xsl:template name="setId">
0033       <xsl:param name="programNames"/>
0034       <xsl:param name="source"/>
0035       <xsl:variable name="programName" select="substring-before($programNames, ',')" />
0036       <xsl:choose>
0037         <xsl:when test="string-length($programName) > 0">
0038           <xsl:variable name="exeName" select="concat($programName, '.exe')" />
0039           <xsl:choose>
0040             <!-- hacking around with contains, as there is no ends-with, should be safe with the possible strings -->
0041             <xsl:when test="contains($source, $exeName)">
0042               <xsl:value-of select="$exeName"/>
0043             </xsl:when>
0044             <xsl:otherwise>
0045               <xsl:call-template name="setId">
0046                 <xsl:with-param name="programNames" select="substring($programNames, string-length($programName)+2)"/>
0047                 <xsl:with-param name="source" select="$source"/>
0048               </xsl:call-template>
0049             </xsl:otherwise>
0050           </xsl:choose>
0051         </xsl:when>
0052         <xsl:otherwise>
0053           <xsl:value-of select="." />
0054         </xsl:otherwise>
0055       </xsl:choose>
0056  
0057     </xsl:template>
0058  
0059     <xsl:template match="wix:File/@Id">
0060       <xsl:variable name="programNames">
0061         <!-- Always also put a final ',' to the last item -->
0062         <xsl:text>braindump,calligrasheets,calligrastage,calligrawords,karbon,</xsl:text>
0063       </xsl:variable>
0064       <xsl:attribute name="Id">
0065         <xsl:call-template name="setId">
0066           <xsl:with-param name="programNames" select="$programNames"/>
0067           <xsl:with-param name="source" select="../@Source"/>
0068         </xsl:call-template>
0069       </xsl:attribute>
0070     </xsl:template>
0071    
0072         <!--Set up keys of component Ids from PreviousHeatFragment.xml-->
0073         <xsl:key name="previousfragment-search" match="wix:Component[@Id = document('PreviousHeatFragment.xml')//wix:Component/@Id]" use="@Id"/>
0074        
0075     <!--Match Components that also exist in PreviousHeatFragment.xml, and use the previous version of the guid-->
0076     <xsl:template match="wix:Component[key('previousfragment-search', @Id)]/@Guid">
0077       <xsl:variable name="Id" select="../@Id"/>
0078       <xsl:attribute name="Guid">
0079         <xsl:value-of select="document('PreviousHeatFragment.xml')//wix:Component[@Id = $Id]/@Guid"/>
0080       </xsl:attribute>
0081     </xsl:template>
0082 </xsl:stylesheet>