nil4 / dotnet-transform-xdt

Modern .NET tools and library for XDT (Xml Document Transformation)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Would you like to fix a bug about removing xmlns?

chucklu opened this issue · comments

1.the target file

<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
  <appSettings>
    <add key="test20180523" value="1" />
  </appSettings>
</configuration>

2.the transform file

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0" xdt:Transform="RemoveAttributes(xmlns)" xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform" />

when I try to apply the transform to the target,nothing happened.

I have tried to debug this, I have found the reason why it' not working.
You can check my comments in following issues
dotnet/aspnetcore#3077
CameronWills/FatAntelope#8

commented

@chucklu I don't necessarily see this as a bug; removing xmlns attributes changes the meaning of the source document.

Is the inability to remove it blocking you? I'd be interested in understanding the use case a bit better.

Since you debugged the issue, would you be interested in submitting a pull request?

I know remove the xmlns attribute has changed the meaning of the source document.
But I have this demand to do this, just remove it.

I have debugged it, but can not fix it.
The source code is complicated for me, I just debugged to find when this bug happened.

I also tried to add a xmlns to a source file(without xmlns), it did not work either.

commented

I don't plan to implement this feature. It's not a common use case, and I would like to avoid this tool drifting away from the original feature set Microsoft implemented.

when the xmlns is not modified between the target file and compared file.
once you encounter such case, then there is no choice to avoid this.
I skip the xmlns as a workaround now, hard code it which make the code ugly.