Automatically remove empty attributes
Having trouble installing Oxygen? Got a bug to report? Post it all here.
-
- Posts: 1
- Joined: Thu Sep 28, 2017 5:36 am
Automatically remove empty attributes
Hi all.
I was curious if OxygenXML has a way to automatically remove empty attributes from a file.
For example, in the file below, the attributes for month, day, image, video, audio, and era are sometimes empty. Is there an efficient way to find and remove those?
Thanks in advance for any help!
--Jason
I was curious if OxygenXML has a way to automatically remove empty attributes from a file.
For example, in the file below, the attributes for month, day, image, video, audio, and era are sometimes empty. Is there an efficient way to find and remove those?
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<timeline>
<date title = "Billy Sunday born" year = "1862" month = "11" day = "9" notes = "William Ashley “Billy” Sunday was born to William and Mary Jane Sunday near Ames, Iowa. Five weeks later, the elder Sunday would die of pneumonia in Missouri while serving as a private in with Iowa’s Twenty-Third Volunteer Infantry Division." category = "fundamentalism" image = "" video = "" audio = "" era = "">
</date>
<date title = "Billy Sunday placed in orphanage" year = "1872" month = "" day = "" notes = "Billy Sunday’s mother placed him and his brother Ed in an orphanage due to the impoverished nature of their lives." category = "fundamentalism" image = "" video = "" audio = "" era = "">
</date>
<date title = "Billy Sunday begins playing professional baseball" year = "1883" month = "" day = "" notes = "Adrian Anson, manager of the Chicago White Stockings, recruited Billy Sunday to play for the team. He would continue to play in Chicago until 1887." category = "fundamentalism" image = "https://sabr.org/sites/default/files/images/AnsonCap-BBHOF.jpg" video = "" audio = "" era = "">
</date>
</timeline>
--Jason
-
- Posts: 9451
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Automatically remove empty attributes
Hi Jason,
Oxygen's Find/Replace dialog has a checkbox which enables support for regular expressions.
For example you can search using this regexp (\s)+[^=]*="".
If you want to do things XML aware, you can right click the XML, choose in the contextual menu Refactoring->Attributes->Delete attribute.
For the element name XPath you can set * and for the attribute XPath you can set @*[.=""]. There is preview functionality which you should use to double check before performing the changes.
Regards,
Radu
Oxygen's Find/Replace dialog has a checkbox which enables support for regular expressions.
For example you can search using this regexp (\s)+[^=]*="".
If you want to do things XML aware, you can right click the XML, choose in the contextual menu Refactoring->Attributes->Delete attribute.
For the element name XPath you can set * and for the attribute XPath you can set @*[.=""]. There is preview functionality which you should use to double check before performing the changes.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ 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