Giter Site home page Giter Site logo

Incorrect condition? about fatantelope HOT 5 CLOSED

myasoex avatar myasoex commented on May 27, 2024
Incorrect condition?

from fatantelope.

Comments (5)

chucklu avatar chucklu commented on May 27, 2024 1

I gave up using this library, currently I am using the linq to xml to migrate the configuration file.

from fatantelope.

Hans-MartinHannibalLauridsen avatar Hans-MartinHannibalLauridsen commented on May 27, 2024

I'm experiencing the same issue

<configuration>  
  <appSettings>
    <add key="KeyA" value="ValueA" />
  </appSettings>  
</configuration>

Target web.config

<configuration>  
  <appSettings>
    <add key="KeyB" value="ValueB" />
    <add key="KeyC" value="ValueC" />    
  </appSettings>  
</configuration>

Transformation

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <appSettings>
    <add xdt:Locator="Condition([(@key='KeyB')])" value="ValueB" xdt:Transform="Replace(value)" />
    <add key="KeyC" value="ValueC" xdt:Transform="Insert" />
  </appSettings>
</configuration>

Again i believe the condition should be xdt:Locator="Condition([(@value='KeyA')])"? It seens like an issue when the transform should remove a lonely leaf node and add new..

from fatantelope.

CameronWills avatar CameronWills commented on May 27, 2024

Hi All,

I've put up a fix now. Apologies for the delay in addressing this - dad life got in the way and then it fell off the radar. It's a tricky one, the xdt:Locator needs to be valid for the current state of the transformed document. And you can omit the xdt:Locator altogether if there is only one node with that name. So after this fix the working patch for @myasoex example looks like:

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <appSettings>
    <add value="1" xdt:Transform="SetAttributes(value)" />
    <add key="MyService.Api" value="2" xdt:Transform="Insert" />
  </appSettings>
</configuration>

And similarly for your example @Hans-MartinHannibalLauridsen , the working generated patch doesn't include an xdt:Locator:

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <appSettings>
    <add key="KeyB" value="ValueB" xdt:Transform="Replace" />
    <add key="KeyC" value="ValueC" xdt:Transform="Insert" />
  </appSettings>
</configuration>

I'll package up and push into nuget shortly.

Cheers,
Cameron

from fatantelope.

Hans-MartinHannibalLauridsen avatar Hans-MartinHannibalLauridsen commented on May 27, 2024

Thanks, much obliged😀

from fatantelope.

CameronWills avatar CameronWills commented on May 27, 2024

Closing as I think that change has addressed the issue?

from fatantelope.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.