Questions about XML that are not covered by the other forums should go here.
- Posts: 18
- Joined: Wed Apr 10, 2019 7:43 pm
Can XML Factoring perform the following operation summarized in the code examples shown below:
Example #1 - Before XML Factoring Operation:
Example #2 - After XML Factoring Operation:
Code: Select all
Code: Select all
In Example #1 the element content shown as "00NS2" needs to move out of where it is located and take the place of the value for the attribute named "manufacturerCodeValue" as shown in Example #2. The "manufacturerCodeValue" attribute needs to be created before this move takes place. Additionally, the content in the <enterpriseRef> element has no set quantity of characters. It can be 3, 5, 8, 11 characters that need to be moved over to the "manufacturerCodeValue" attribute value location. In other words, X amount of numbers and digits need to be moved over to the value location of the "manufacturerCodeValue" attribute. Is such an operation possible?
- Posts: 2533
- Joined: Tue May 17, 2005 4:01 pm
There is no such refactoring operation available at this time (extract text node and use it as attribute value).
I guess you can use the "good old fashioned" regular expression from the Find/Replace tool.
[x] Regular expression
If you'd like to limit the location from the XML where this acts, you can additionally specify an XPath expression. e.g.
If you use Find/Replace in Files to apply this on multiple files, I recommend using Preview first. Also, it's always a good idea to have a backup copy of the files.
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger