Can Element Content be moved to Attribute Value location?
Questions about XML that are not covered by the other forums should go here.
-
- Posts: 26
- Joined: Wed Apr 10, 2019 7:43 pm
Can Element Content be moved to Attribute Value location?
Greetings,
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:
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?
Can XML Factoring perform the following operation summarized in the code examples shown below:
Example #1 - Before XML Factoring Operation:
Code: Select all
<procurementData>
<enterpriseRef>00NS2</enterpriseRef>
</procurementData>
Code: Select all
<procurementData>
<enterpriseRef manufacturerCodeValue="00NS2"></enterpriseRef>
</procurementData>
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: Can Element Content be moved to Attribute Value location?
Hello,
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.
Search for:
<enterpriseRef>(.*)</enterpriseRef>
Replace with:
<enterpriseRef manufacturerCodeValue="$1"></enterpriseRef>
[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.
//procurementData/enterpriseRef
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.
Regards,
Adrian
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.
Search for:
<enterpriseRef>(.*)</enterpriseRef>
Replace with:
<enterpriseRef manufacturerCodeValue="$1"></enterpriseRef>
[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.
//procurementData/enterpriseRef
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.
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Return to “General XML Questions”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service