nil4 / dotnet-transform-xdt

Modern .NET tools and library for XDT (Xml Document Transformation)
Apache License 2.0
118 stars 12 forks source link

Would you like to fix a bug about removing xmlns? #21

Closed chucklu closed 6 years ago

chucklu commented 6 years ago

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.

chucklu commented 6 years ago

I have tried to debug this, I have found the reason why it' not working. You can check my comments in following issues https://github.com/aspnet/Home/issues/3077 https://github.com/CameronWills/FatAntelope/issues/8

nil4 commented 6 years ago

@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?

chucklu commented 6 years ago

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.

chucklu commented 6 years ago

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

nil4 commented 6 years ago

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.

chucklu commented 6 years ago

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.