在包含反斜杠的“test”字符串中使用XSLT变量

在包含反斜杠的“test”字符串中使用XSLT变量,xslt,Xslt,我正试图编写一个XSLT文件,与Wix收获工具一起使用。下面是该工具生成的XML的伪代码示例: <?xml version="1.0" encoding="utf-8"?> <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> <Fragment> <DirectoryRef Id="APPLICATIONFOLDER"> <Compone

我正试图编写一个XSLT文件,与Wix收获工具一起使用。下面是该工具生成的XML的伪代码示例:

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
        <DirectoryRef Id="APPLICATIONFOLDER">
            <Component Id="component1" Guid="{guidstring1}">
                <File Id="file1" Source="SourceDir\target.exe" KeyPath="yes" />
            </Component>
            <Component Id="component2" Guid="{guidstring2}">
                <File Id="file2" Source="SourceDir\otherfile.txt" KeyPath="yes" />
            </Component>
当我显式设置when测试字符串时,这个XSLT文件完成了我希望它完成的任务。但是,我想使用我在开始时定义的targetFile参数。我的第一次尝试是使用以下内容:

<xsl:when test='not (@Source = SourceDir\$targetFile)'>
没有正确识别文件组件,只是对所有内容应用了KeyPath属性修改

将变量设置为,然后将测试设置为

<xsl:when test='not (@Source = $targetFile)'>
导致了正确的修改,但是我希望在XSLT文件的其他地方使用target.exe字符串,因此我希望将变量设置为该值

此时,我怀疑我对该操作使用了错误的语法,但我试图查找文档以澄清问题,但迄今为止没有成功。

只需使用concat函数@Source=concatSourceDir\,$targetFile即可

Expected token ')', found '\'. not (@Source = SourceDir -->\<-- $targetFile)
<xsl:when test='not (@Source = "SourceDir\$targetFile")'>
<xsl:when test='not (@Source = $targetFile)'>