我有一個 wix (.wxs) 檔案的示例:
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="INSTALLLOCATION">
<Component Id="cmpE48528C4F5932A4EFD89F7331108F45D" Guid="*">
<File Id="filF1B84C2C6BCC693224B7A7959445B74F" KeyPath="yes" Source="$(var.SourceDir)\MyFont.ttf" />
</Component>
<Component Id="cmpE48528C4F5932A4EFD89F7331108F45D" Guid="*">
<File Id="filF1B84C2C6BCC693224B7A7959445B74F" KeyPath="yes" Source="$(var.SourceDir)\Newtonsoft.Json.dll" />
</Component>
</DirectoryRef>
</Fragment>
</Wix>
現在我想將屬性添加TrueType="yes"到 Source 以“ttf”結尾的所有檔案元素中。
所以它應該是這樣的:
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="INSTALLLOCATION">
<Component Id="cmpE48528C4F5932A4EFD89F7331108F45D" Guid="*">
<File Id="filF1B84C2C6BCC693224B7A7959445B74F" KeyPath="yes" TrueType="yes" Source="$(var.SourceDir)\MyFont.ttf" />
</Component>
<Component Id="cmpE48528C4F5932A4EFD89F7331108F45D" Guid="*">
<File Id="filF1B84C2C6BCC693224B7A7959445B74F" KeyPath="yes" Source="$(var.SourceDir)\Newtonsoft.Json.dll" />
</Component>
</DirectoryRef>
</Fragment>
</Wix>
這是我目前擁有的 XSLT,但它不起作用(還):
<?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"
xmlns:my="my:my">
<xsl:output method="xml" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match='//File[ends-with(@Source , 'ttf')]'>
<xsl:attribute name="TrueType">
<xsl:value-of select="yes"/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
如何應用此 end-with() 函式?
uj5u.com熱心網友回復:
這是您可以執行此操作的一種方法:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:wi="http://schemas.microsoft.com/wix/2006/wi"
version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="wi:File">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:if test="substring(@Source,string-length(@Source)-2)='ttf'">
<xsl:attribute name="TrueType">yes</xsl:attribute>
</xsl:if>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
看到它在這里作業:https ://xsltfiddle.liberty-development.net/pNP54et
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/447876.html
