1
我試圖用一個轉換爲一個組件描述添加一個屬性。它正確地添加屬性,但會弄亂我的XML格式。WiX XSLT轉換搞亂了我的格式化
我的目標是屬性「永久=‘是’」添加到組件。
的XSLT是:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:wix="http://schemas.microsoft.com/wix/2006/wi">
<xsl:template match="wix:Component">
<xsl:copy>
<xsl:apply-templates select="@*" />
<xsl:attribute name="Permanent">
<xsl:text>yes</xsl:text>
</xsl:attribute>
<xsl:apply-templates select="*" />
</xsl:copy>
</xsl:template>
<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates select="@*" />
<xsl:apply-templates select="* | text()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@* | text()">
<xsl:copy />
</xsl:template>
<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>
</xsl:stylesheet>
的.wxl文件之前轉換如下所示:
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="SystemFolder">
<Component Id="tdbgpp7.dll" Guid="{FA172CDA-D111-49BD-940F-F72EB8AC90DA}">
<File Id="tdbgpp7.dll" KeyPath="yes" Source="$(var.OC2.WinSys32)\tdbgpp7.dll" />
</Component>
</DirectoryRef>
</Fragment>
</Wix>
和轉換看起來像這樣經過:
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="SystemFolder">
<Component Id="tdbgpp7.dll" Guid="{415E5416-AFE3-4658-8D74-489554345219}" Permanent="yes"><File Id="tdbgpp7.dll" KeyPath="yes" Source="$(var.OC2.WinSys32)\tdbgpp7.dll" /></Component>
</DirectoryRef>
</Fragment>
</Wix>
,你可以看到它正在按預期添加我的屬性,但它失去了一些格式。該代碼仍然有效,但失去了可讀性。我知道我一定錯過了一些簡單的事情,但到目前爲止它並沒有讓我感到滿意我是這個變換的東西的小白菜。
謝謝你,非常完美。正是我需要的。 – gagidlof
@gagidlof - 非常受歡迎。請點擊旁邊的複選標記(✅)接受此答案。謝謝! –