Question

I would like to use xslt to edit .wxs file which was generated from heat in wix

this is components_en_us.wxs

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
        <Fragment>
            <DirectoryRef Id="CLASSES">
                <Directory Id="dirAB609E465A12655D740B32B2BA26C468" Name="alfresco">
                <Directory Id="dir68A1A3CC25353B021B1D7D979B520AF0" Name="extension">
                    <Component Id="cmp0FAE663628DD6BAE53501BB26264259B" Guid="1CBE6568-96E5-4844-BF02-99AF0DE1719D">
                        <File Id="fil867FDB2D2761B5912BA54F92F5E928D1" KeyPath="yes" Source="SourceDir\alfresco\extension\web-client-config-custom.xml" />
                    </Component>
                </Directory>
                </Directory>
            </DirectoryRef>
    </Fragment>
</Wix>

but the problem is I have others .wxs files (components_xx_yy.wxs for other languages) and the Component/File Id are the same. If I compile using this method I will get an error

error LGHT0091 : Duplicate symbol 'Component:cmp0FAE663628DD6BAE53501BB26264259B' found. 
This typically me ans that an Id is duplicated. Check to make sure all your identifiers 
of a given type (File, Component, Feature) are unique.

I googled and found that I may use the xslt to change the Component/File id in components_en_us.wxs

So, I expect something like

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
        <DirectoryRef Id="CLASSES">
            <Directory Id="dirAB609E465A12655D740B32B2BA26C468" Name="alfresco">
            <Directory Id="dir68A1A3CC25353B021B1D7D979B520AF0" Name="extension">
                <Component Id="en_US_cmp0FAE663628DD6BAE53501BB26264259B" Guid="1CBE6568-96E5-4844-BF02-99AF0DE1719D">
                    <File Id="fil867FDB2D2761B5912BA54F92F5E928D1" KeyPath="yes" Source="SourceDir\alfresco\extension\web-client-config-custom.xml" />
                </Component>
            </Directory>
            </Directory>
        </DirectoryRef>
    </Fragment>
</Wix>

right now, I have this xslt from another question but I have no idea how to implement it like I want.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
          xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
          xmlns:msxsl="urn:schemas-microsoft-com:xslt"
          exclude-result-prefixes="msxsl"
          xmlns:wix="http://schemas.microsoft.com/wix/2006/wi">

  <xsl:output method="xml" indent="yes"/>

  <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>

So, please, correct me if my understanding is wrong and please help me with .xslt too

Thanks in advance

edit : Is this way a best practice, or should I do something else to solve this duplication error.

Was it helpful?

Solution

The only change I can find between those two XML listings is the addition of "en_US_" before the component ID. Is that everything? If so, please try adding this template to your current XSLT file:

<xsl:template match="wix:Component/@Id">
   <xsl:attribute name="{name()}">
     <xsl:value-of select="concat('en_US_', .)" />
   </xsl:attribute>
</xsl:template>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top