2
是否有可能將XML文件(例如配置文件)中的節點標記爲「必須轉換」,並且如果您沒有在轉換文件中指定它,轉換將失敗?是否有可能將XML節點標記爲「必須轉換」?
例如,採取以下由一個.config
文件與一個節點必須被轉化的例如:
<?xml version="1.0"?>
<configuration>
<appSettings>
<!-- Mark this key to be transformed -->
<add key="MyValue" MustBeTransformed="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2" />
</system.web>
</configuration>
由於密鑰值被標記爲MustBeTransformed
,下面將確保它是正確的轉化:
<?xml version="1.0" encoding="utf-8"?>
<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
<!-- Without the line below, the transform would fail -->
<add key="MyValue" xdt:Transform="Set a value" />
</appSettings>
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
</system.web>
</configuration>
我問這個是因爲在現階段,我只看到這一點使用.ps1
腳本和是可能的XPath
你是什麼意思,「必須改變」?您的意思是「必須通過'xsl:apply-templates'指令來選擇嗎?或者您的意思是」必須匹配除內置模板規則之外的模板規則「?或者是否足以被選中,例如,在一個'xsl:for-each'或'xsl:copy-of'指令? –
這是一個很好的問題。我想確保對於任何發生的轉換,爲每個鍵提供值。在節點上已經設置了一個屬性將是一個很好的開始,我猜 – Luke