Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
发布时如何转换XML文件?_Xml_Xslt_Transform_Slowcheetah - Fatal编程技术网

发布时如何转换XML文件?

发布时如何转换XML文件?,xml,xslt,transform,slowcheetah,Xml,Xslt,Transform,Slowcheetah,我有一个xml文件,它将根据部署到的环境具有不同的值。到目前为止,我已经安装了Slow Cheetah,它允许我对xml文件进行转换,但是我不确定使用什么语法,因为它与配置文件不同 以下是我到目前为止的情况: AppConfig.Dev.xml <?xml version="1.0" encoding="utf-8" ?> <!-- For more information on using transformations see the web.config exampl

我有一个xml文件,它将根据部署到的环境具有不同的值。到目前为止,我已经安装了Slow Cheetah,它允许我对xml文件进行转换,但是我不确定使用什么语法,因为它与配置文件不同

以下是我到目前为止的情况: AppConfig.Dev.xml

<?xml version="1.0" encoding="utf-8" ?>
<!-- For more information on using transformations 
 see the web.config examples at http://go.microsoft.com/fwlink/?LinkId=214134. -->
<config xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">

    <application name="HSMED">
        <appHost>dev</appHost>  //not sure how to specify transform
    </application>
</config>

dev//不确定如何指定转换

语法与.config文件相同。配置文件也是用XML编写的,因此应该可以正常工作。我给了一个样品以防万一

<?xml version="1.0" encoding="utf-8" ?>
<!-- For more information on using transformations 
see the web.config examples at http://go.microsoft.com/fwlink/?LinkId=214134. -->
<config xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
    <application name="HSMED">
        <appHost xdt:Transform="Replace">PROD</appHost>
    </application>
</config>
如果您想验证这一点,还可以检查csproj文件,并确保它看起来像这样。我注意到,当您启用DependentUpon和TransformOnBuild子标记进行转换时,slowcheetah会将它们添加到文件中。不知道为什么

<None Include="Config\somefile.Prod.xml">
  <DependentUpon>somefile.xml</DependentUpon>
  <IsTransformFile>True</IsTransformFile>
</None>
<Content Include="Config\somefile.xml">
  <TransformOnBuild>true</TransformOnBuild>
</Content>

somefile.xml
真的
真的