我正在使用wix,並且需要安裝Windows服務。 作爲其中的一部分,我只需要在服務可執行文件上設置KeyPath="yes"
。 我使用HarvestDirectory
任務,其輸出像這樣:XSLT替換除一個節點以外的所有節點上的屬性
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="INSTALLFOLDER">
<Component Id="cmp4BB0346D363B37CAFD72ED8BBAFE3DC3" Guid="*">
<File Id="fil1F519C40510B9CE08968AFE1141C5124" KeyPath="yes" Source="$(var.My.Awesome.Product.TargetDir)\My.Awesome.Product.dll" />
</Component>
<!-- Many more here -->
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductFiles">
<ComponentRef Id="cmp4BB0346D363B37CAFD72ED8BBAFE3DC3" />
<!-- Many more here -->
</ComponentGroup>
</Fragment>
</Wix>
我想要做的是寫一個XSLT會改變的keyPath爲「no」的所有文件,除非源= $(var.My.Awesome.Product.TargetDir)\My.Awesome.Product.exe
例如樣本輸出將是:
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="INSTALLFOLDER">
<Component Id="cmp4BB0346D363B37CAFD72ED8BBAFE3DC3" Guid="*">
<!-- note the 'no' in the KeyPath here -->
<File Id="fil1F519C40510B9CE08968AFE1141C5124" KeyPath="no" Source="$(var.My.Awesome.Product.TargetDir)\My.Awesome.Product.dll" />
</Component>
<Component Id="cmp5BB0346D363B37CAFD72ED8BBAFE3DC3" Guid="*">
<File Id="fil2F519C40510B9CE08968AFE1141C5124" KeyPath="yes" Source="$(var.My.Awesome.Product.TargetDir)\My.Awesome.Product.exe" />
</Component>
<!-- Many more here -->
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductFiles">
<ComponentRef Id="cmp4BB0346D363B37CAFD72ED8BBAFE3DC3" />
<ComponentRef Id="cmp5BB0346D363B37CAFD72ED8BBAFE3DC3" />
<!-- Many more here -->
</ComponentGroup>
</Fragment>
</Wix>
我有以下XSLT替換「是」與「否」上的所有的keyPath屬性:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:wix="http://schemas.microsoft.com/wix/2006/wi">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@KeyPath">
<xsl:attribute name="KeyPath">
<xsl:value-of select="'no'"/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
我試着用parent
操縱比賽的第二個模板,ancestor
和具有屬性的簡單節點File[@KeyPath='yes']
選擇器無濟於事。
'File [@KeyPath ='yes']'當'File'位於**名稱空間中時不會選擇任何內容** - 請參閱:https://stackoverflow.com/questions/34758492/xslt-transform-doesnt -work-until-i-remove-root-node/34762628#34762628 –
@ michael.hor257k當然,但是我怎樣才能取代除了一個之外的所有? – zaitsman