zoukankan      html  css  js  c++  java
  • wix xslt for adding node

    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>
  • 相关阅读:
    LTE网络注册流程(1)(2)(3)
    Linux 添加用户
    (TOJ2627)台州学院首届新生程序设计竞赛参赛资格
    (TOJ1249)四数相加
    (TOJ1192)A + B Problem II
    (TOJ1065)完美数
    (TOJ1248)Encoding
    (TOJ1051)A × B problem
    (TOJ1506)Sort ZOJ7
    (TOJ1531)爱的伟大意义
  • 原文地址:https://www.cnblogs.com/cindy-hu-23/p/5036002.html
Copyright © 2011-2022 走看看