0

I am using xdt transforms to modify my Sitecore.config file for different environments. I want to remove a role:require="!ContentDelivery" attribute.

I'm targeting the following element:

<databases>
  <!-- core -->
    <database id="core" singleInstance="true" type="Sitecore.Data.DefaultDatabase, Sitecore.Kernel" role:require="!ContentDelivery">

and want to remove the role:require="!ContentDelivery" attribute.

If I use the following xdt syntax

<database id="core" singleInstance="true" type="Sitecore.Data.DefaultDatabase, Sitecore.Kernel" xdt:Locator="Match(id)" xdt:Transform="RemoveAttributes(role:require)"/>

I get the error "Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function.".

If I omit the namespace prefix i.e.

<database id="core" singleInstance="true" type="Sitecore.Data.DefaultDatabase, Sitecore.Kernel" xdt:Locator="Match(id)" xdt:Transform="RemoveAttributes(require)"/>

It doesn't work.

Is there a solution to this, or perhaps a better way to solve the problem?

2
  • In what conditions would the transform run? Would it be less complicated to use the patching system to override based on Environment variables? blog.vitaliitylyk.com/… Oct 16, 2022 at 21:51
  • It would run at project build/compile time to generate the output Sitecore.config file. Easier solution is to just modify Sitecore.config and remove that role:require attribute, but I wanted to try and avoid modifying Sitecore.config directly. Oct 16, 2022 at 21:57

2 Answers 2

0

You can use Replace syntax:

<database id="core" singleInstance="true" type="Sitecore.Data.DefaultDatabase, Sitecore.Kernel" xdt:Locator="Match(id)" xdt:Transform="Replace"/>

You can find references to the details and another syntax: Web.config Transformation Syntax for Web Project Deployment Using Visual Studio

1
  • I did get this technique to work, so this is sometimes a good solution, but in my case, I did not want to duplicate the whole database configuration elements. Oct 17, 2022 at 8:35
0

xdt:Transform="RemoveAttributes(role:require)" should work correctly. But you need to remember to add xmlns:role="http://www.sitecore.net/xmlconfig/role/" attribute to the <configuration> tag of your tranform config file:

<configuration xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <databases>
    <database xdt:Transform="RemoveAttributes(role:require)" />
  </databases>
</configuration>
1
  • I tried this, but could not get it to work. Oct 17, 2022 at 8:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.