How to delete an attribute from some elements selected by XPath?
Posted: Tue Aug 02, 2016 7:33 pm
I have an XML document which contains structures such as this one:
Now from all Elements "a" I want to delete the attribute "x" if the text of "Code" has no lines with more than 10 characters. Or in short: I want to delete
from my document.
If I enter the above XPath-Expression into the XPath-Search box I only get a single result: The attribute that I want to delete.
In the menu, I found the Option Tools->XML Refactoring->Attributes->Delete attribute. I can specify an XPath expression there from which an attribute can be deleted. Great! Except that my conditions are completely ignored. Oxygen will always delete all attributes "x" in the whole document. It will even remove the attribute "x" from "<b x="" />". It feels like the XPath is completely ignored. However if I supply an XPath that yields zero nodes in the whole document, no changes are performed.
What is going on there and how can I do what I would like to do?
Code: Select all
<a x="">
<Code>short</Code>
</a>
<a x="">
<Code>looooooonnnngggggggg</Code>
</a>
Code: Select all
//a[Code[not(matches(text(), '[^\n]{10,}'))]]/@x
If I enter the above XPath-Expression into the XPath-Search box I only get a single result: The attribute that I want to delete.
In the menu, I found the Option Tools->XML Refactoring->Attributes->Delete attribute. I can specify an XPath expression there from which an attribute can be deleted. Great! Except that my conditions are completely ignored. Oxygen will always delete all attributes "x" in the whole document. It will even remove the attribute "x" from "<b x="" />". It feels like the XPath is completely ignored. However if I supply an XPath that yields zero nodes in the whole document, no changes are performed.
What is going on there and how can I do what I would like to do?