码迷,mamicode.com
首页 > 其他好文 > 详细

wix xslt for adding node

时间:2015-12-10 14:57:47      阅读:198      评论:0      收藏:0      [点我收藏+]

标签:

Using xslt to add new node item to wix source code.

 

Original wix code:

  <Fragment>
    <DirectoryRef Id="TARGETDIR">
      <Component Guid="*" Id="Test.txt">
        <File KeyPath="yes" Source="$(var.TestFolder)\Test.txt" Id="Test.txt" />
      </Component>
    </DirectoryRef>
  </Fragment>

 

Add <CopyFile /> node inside <File> node, the expected wix code would be:

  <Fragment>
    <DirectoryRef Id="TARGETDIR">
      <Component Guid="*" Id="Test.txt">
        <File KeyPath="yes" Source="$(var.TestFolder)\Test.txt" Id="Test.txt" >
          <CopyFile Id ="Test.txt" DestinationProperty="BinFolder" DestinationName="test.txt" />
        </File>
      </Component>
    </DirectoryRef>
  </Fragment>

 

Pass this xslt to heat.exe with -t option should do the work:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:wi="http://schemas.microsoft.com/wix/2006/wi" exclude-result-prefixes="wi">
  <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:variable name="leadingSpace" select="preceding-sibling::text()[1]" />
      <xsl:apply-templates select="@*"/>
      <!-- Add linebreak and indentation, as requested in the comments -->
      <xsl:value-of select="concat($leadingSpace, ‘    ‘)" />
      <CopyFile xmlns="http://schemas.microsoft.com/wix/2006/wi" Id="Test.txt" DestinationProperty="BinFolder" DestinationName="test.txt"/>
      <!-- Linebreak and indentation -->
      <xsl:value-of select="$leadingSpace"/>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>

 

wix xslt for adding node

标签:

原文地址:http://www.cnblogs.com/cindy-hu-23/p/5036002.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!