Page 1 of 1

XML refactoring preview highlights namespace declarations

Posted: Fri Nov 03, 2017 10:25 pm
by mboudreau
I'm exploring the XML Refactoring tool, and I decided to try making a simple change: sec/title => sec/label

In the 'Rename element' dialog box, I specified this:
https://www.dropbox.com/s/rpiojvn5odi47 ... 1.png?dl=0

But the preview showed this, highlighting namespace declaration changes that I didn't request:
https://www.dropbox.com/s/byhwjdlxy95yd ... 2.png?dl=0

It turns out the preview also showed the changes I wanted, but I had to scroll past a number of namespace declaration changes to find them. When I clicked Finish, the changes I wanted were made, but all the highlighted namespace declarations had been deleted as well.

Shouldn't the refactoring tool make only the requested changes?

Re: XML refactoring preview highlights namespace declarations

Posted: Wed Nov 08, 2017 1:24 pm
by alin
Hello,

I was able to obtain a similar situation using the XML document listed below:

Code: Select all


<root xmlns:ns="my-ns">
<other
xmlns:ns="my-ns"
ns:attr="value"/>
<sec>
<title>My Title</title>
</sec>
</root>
As you can see, in my case, the namespace declaration is redundant as it appears once on the root element and once on the <other> element.
Is this also true for your documents? If not, please send us a sample to reproduce the problem.

Although these changes may be unwanted and they may clutter the preview dialog, the resulted document is XML-equivalent with the original one from the namespaces context point of view. The XML Refactoring processor tries to limit the amount of changes performed on the input documents but it is not 100% accurate. Under the hood an XML Refactoring operation is in fact an XQuery Update or XSLT transformation performed with some tweaks and restrictions in order to minimize unwanted changes. In the case I have described above, the namespaces declarations are optimized by the XQuery Update / XSLT processor which triggers the removal of the redundant declarations.
You can read more about how an XML Refactoring operation is applied on a document here: https://www.oxygenxml.com/doc/versions/ ... tools.html

Regards,
Alin

Re: XML refactoring preview highlights namespace declarations

Posted: Wed Nov 08, 2017 7:16 pm
by mboudreau
Hi Alin,

Yes, the 'xlink' namespace is also defined on the root element of my document. I don't know why the redundant declaration occurs, but unfortunately I have no control over the files I'm given to work with.

It would be convenient if there were an 'Ignore namespaces' option, as there is in the Diff tool.

Re: XML refactoring preview highlights namespace declarations

Posted: Tue Nov 14, 2017 3:58 pm
by alin
Hello,

Thank you for your feedback! I have logged your request in our issue tracking tool.

Regards,
Alin