2012-01-12 33 views

回答

4

對由熱生成的片段應用XSLT轉換,並將ReadOnly="yes"添加到每個File元素。此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:File"> 
     <xsl:copy> 
      <xsl:apply-templates select="@*" /> 
      <xsl:attribute name="ReadOnly"> 
       <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> 
+0

對於XML虛擬:您如何應用此轉換? – harper 2012-01-13 17:22:32

+0

@harper你必須使用一個變形器,例如[Xalan](http://xml.apache.org/xalan-j/)或[Saxon](http://saxon.sourceforge.net/ )。這兩個都是Java應用程序。由於這一步是構建過程,因此可以使用[Ant](http://ant.apache.org/)的[XSLT任務](http://ant.apache.org/manual/Tasks/style)。 HTML)。還有其他工具。 – 2012-01-13 19:41:44

+0

這是一個簡單的C#表單應用程序來轉換XML http://www.daniweb.com/software-development/csharp/threads/308973/xml-transformer – 2014-06-12 14:05:26

相關問題