0

我们的配置文件之一正在被奇怪地转换。

基本配置

<?xml version="1.0"?>
<configuration >

</configuration>

发布配置(因为它在项目中,为简洁起见被截断)

<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform" xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore xdt:Transform="Insert">
    <contentSearch>
      <configuration>
        <indexes>
          <index id="sitecore_web_index">
            <param desc="core" patch:instead="param[@desc='core']">#{IndexEnvironment}#_web_index</param>
          </index>
        </indexes>
        <indexes role:require="Standalone or ContentManagement">
          <index id="sitecore_master_index">
            <param desc="core" patch:instead="param[@desc='core']">#{IndexEnvironment}#_master_index</param>
          </index>

运行构建后,最终配置的输出看起来很奇怪:

后期构建

<?xml version="1.0"?>
<configuration>
    <sitecore>
        <contentSearch>
            <configuration>
                <indexes>
                    <index id="sitecore_web_index">
                        <param desc="core" d7p1:instead="param[@desc='core']" xmlns:d7p1="http://www.sitecore.net/xmlconfig/">ASHQA_web_index</param>
                    </index>
                </indexes>
                <indexes d5p1:require="Standalone or ContentManagement" xmlns:d5p1="http://www.sitecore.net/xmlconfig/role/">
                    <index id="sitecore_master_index">
                        <param desc="core" d7p1:instead="param[@desc='core']" xmlns:d7p1="http://www.sitecore.net/xmlconfig/">ASHQA_master_index</param>
                    </index>

注意patchrole定义如何分别更改为d7p1d5p1

虽然这是有效的 XML,但它会在我们的应用程序中引起问题,该应用程序解析 XML 并查找正确的patch和术语role

4

1 回答 1

2

TL;博士

转换后的配置中所需的任何命名空间都需要在基本配置中定义。

基本配置更新

<?xml version="1.0"?>
<configuration xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:patch="http://www.sitecore.net/xmlconfig/">

</configuration>

即使基本配置不依赖这些命名空间,如果不包含它们,它们也不会正确继承。这也按预期清理了结果配置的输出:

<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform" xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:patch="http://www.sitecore.net/xmlconfig/">
    <sitecore>
        <contentSearch>
            <configuration>
                <indexes>
                    <index id="sitecore_web_index">
                        <param desc="core" patch:instead="param[@desc='core']">#{IndexEnvironment}#_web_index</param>
                    </index>
                </indexes>
                <indexes role:require="Standalone or ContentManagement">
                    <index id="sitecore_master_index">
                        <param desc="core" patch:instead="param[@desc='core']">#{IndexEnvironment}#_master_index</param>
                    </index>
于 2019-05-30T14:45:29.750 回答