1

I am trying to insert a dependentAssembly element into my config where the child assemblyIdentity element doesn't already exist. However, I'm getting the following error

No element in the source document matches '/configuration/runtime/_defaultNamespace:assemblyBinding/_defaultNamespace:dependentAssembly[assemblyIdentity/@name='System.Web.Extensions']'

Below the relevant snippet of my config file and transform file. Are there any gurus here at Xslt transform that could help?

Sample Transform

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
   <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly xdt:Transform="InsertIfMissing" xdt:Locator="Condition(assemblyIdentity/@name='System.Web.Extensions')">
        <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" xdt:Transform="SetAttributes" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

Sample Configuration

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
<configuration>
PatrickNolan
  • 1,671
  • 2
  • 20
  • 40
  • I don't know how this relates to XSLT but obviously, given that the `assemblyIdentity` element is in the same namespace as the parent and grandparent it is not likely that the path `/configuration/runtime/_defaultNamespace:assemblyBinding/_defaultNamespace:dependentAssembly[assemblyIdentity/@name='System.Web.Extensions']` selects the element, I would expect that to be e.g. `/configuration/runtime/_defaultNamespace:assemblyBinding/_defaultNamespace:dependentAssembly[_defaultNamespace:assemblyIdentity/@name='System.Web.Extensions']`. – Martin Honnen Jan 11 '18 at 11:32
  • 1
    Not sure where you could specify that in your file but you could revert to write the syntax agnostic condition `xdt:Locator="Condition(*[local-name() = 'assemblyIdentity']/@name='System.Web.Extensions')"` – Martin Honnen Jan 11 '18 at 11:33
  • I just got an answer for a similar question, basically u should consider the namespace in your condition: https://stackoverflow.com/questions/54185439/xdt-transforms-by-a-child-node-attribute – Ofir Jan 16 '19 at 07:33

0 Answers0