Convert (from nwctxt to xml) and back (from xml to nwctxt) 2009-08-08 04:55 am I have written two Python 3 programs: 1. nwctxt2xml.py - Converts nwctxt into XML 2. xml2nwctxt.py - Converts XML into nwctxt I have done about a dozen "round trip" tests. All results ran OK. Here is a round trip test: 1. nwctxt2xml.py converts mySong.nwctxt to mySong.xml 2. xml2nwctxt.py converts mySong.xml to mySong-out.nwctxt 3. If fileCompare (mySong.nwctxt, mySong-out.nwctxt) = "files are identical" -> OKHaving said that, these programs are distributed in the hope that they will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. They are subject to the GNU General Public License 3. See each source code listing.You can download a zip distribution file at https://sourceforge.net/projects/rtcnwctxt-xml/The zip distribution contains 4 files: 0. readme.txt 1. nwctxt2xml.py - Converts nwctxt into XML - Python 3.1 source code 2. xml2nwctxt.py - Converts XML into nwctxt - Python 3.1 source code 4. GPL-3.txt - GNU GENERAL PUBLIC LICENSE Version 3 details Contact me at JoeCodeswell@gmail.com All the best,JoePROGRAM DOC BRIEFS1. nwctxt2xml.py Copyright © 2009 Joe Dorocak (JoeCodeswell@gmail.com) Subject to GNU General Public License 3 (see source code listing) nwctxt2xml.py converts nwctxt into XML Requires: Python 3.1+Usage: nwctxt2xml.py infile.nwctxt outfile.xmlExample: nwctxt2xml.py mySong.nwctxt mySong.xmlnwctxt2xml.py Converts From: nwctxt format To: Joe Dorocak's xml format. See below for XML structure: <jNoteWorthyComposer> <SongInfo></SongInfo> <PgSetup></PgSetup> <jFonts><Font></Font></jFonts> <PgMargins></PgMargins> <jStaves> <jStaff> <AddStaff></AddStaff> <StaffProperties></StaffProperties> <StaffInstrument></StaffInstrument> <Clef></Clef> <Key></Key> <Tempo></Tempo> <Note></Note> <Chord></Chord> <Bar></Bar> </jStaff> </jStaves> </jNoteWorthyComposer> Note: The xml elements <jFonts>, <jStaves> and <jStaff> were added to those elements directly derived from the nwctxt format. 2. xml2nwctxt.py Copyright © 2009 Joe Dorocak (JoeCodeswell@gmail.com) Subject to GNU General Public License 3 (see source code listing)xml2nwctxt.py converts XML into nwctxtRequires: Python 3.1+Usage: xml2nwctxt.py infile.xml outfile.nwctxt Example: xml2nwctxt.py mySong.xml mySong.nwctxtxml2nwctxt.py Converts To: nwctxt format From: Joe Dorocak's xml format. See below for XML structure: <jNoteWorthyComposer> <SongInfo></SongInfo> <PgSetup></PgSetup> <jFonts><Font></Font></jFonts> <PgMargins></PgMargins> <jStaves> <jStaff> <AddStaff></AddStaff> <StaffProperties></StaffProperties> <StaffInstrument></StaffInstrument> <Clef></Clef> <Key></Key> <Tempo></Tempo> <Note></Note> <Chord></Chord> <Bar></Bar> </jStaff> </jStaves> </jNoteWorthyComposer> Note: The xml elements <jFonts>, <jStaves> and <jStaff> were added to those elements directly derived from the nwctxt format. Quote Selected Last Edit: 2009-08-13 05:23 am by jdorocak
Re: Convert (from nwctxt to xml) and back (from xml to nwctxt) Reply #1 – 2009-08-09 07:46 am Great piece of work here Joe.I confirm that for a number of NWc files, I have sucessfully exported to nwctxtUsed your program to convert to xmlUsed your program to convert back to nwctxt and then loaded into NWC2. All looks to be identical.That could be useful in a number of instances.However, I would like to report the following issues that you may or may not wish to consider.The program seems to not like xml files generated from elsewhere (ie scanning software).This would be more useful (to me) if it was able to attempt to convert such an xml file to nwctxt (in the same way that Nicolas Hatier's program does).The ones I have attempted give the following :QuoteD:\pythonfiles>xml2nwctxt.py bwv140002.xml test.nwctxtbwv140002.xml test.nwctxtTraceback (most recent call last): File "D:\pythonfiles\xml2nwctxt.py", line 152, in <module> sys.exit(main()) File "D:\pythonfiles\xml2nwctxt.py", line 148, in main sNwc = x2t.convertToNwctxt() # translate sXml into sNwc File "D:\pythonfiles\xml2nwctxt.py", line 118, in convertToNwctxt self.procLeaves(nKid) File "D:\pythonfiles\xml2nwctxt.py", line 133, in procLeaves name = a.tag; value = unescape(a.text, {'"':'"'}) # changed for python 3 File "C:\Python31\lib\xml\sax\saxutils.py", line 48, in unescape data = data.replace("<", "<")AttributeError: 'NoneType' object has no attribute 'replace'(This means nothing to me !)Also, if I take a nwctxt file and convert it to xml using nwctxt2xml.py and then try to feed it into Nicolas' program, this comes back and reports that the xml file is not a music xml file.I suspect that all music xml files should be recognisable as such and fully interchangeable between different programs.You may not have intended your programs to be able to generate data files that are interchangeable with other programs and if not, that would be a shame.Any comments ?Cheers Quote Selected
Re: Convert (from nwctxt to xml) and back (from xml to nwctxt) Reply #2 – 2009-08-11 05:23 pm Dear Rich,Thanks ever so much for your gracious reply. I braced myself for this effort being only useful to me. It makes me very glad that someone else thinks it might be useful as well. I'll look into the issue you described and report back.Thanks again for the encouragement. Quote Selected Last Edit: 2009-08-11 06:31 pm by jdorocak
Re: Convert (from nwctxt to xml) and back (from xml to nwctxt) Reply #3 – 2009-08-12 04:24 am Joe, thank you for writing these routines. Do you see this as a way to, ultimately, convert a NWC2 file into musicxml via NWCtext, so it can be imported into other programs? Quote Selected
Re: Convert (from nwctxt to xml) and back (from xml to nwctxt) Reply #4 – 2009-08-12 09:28 am Quote from: David Palmquist – 2009-08-12 04:24 amJoe, thank you for writing these routines. Do you see this as a way to, ultimately, convert a NWC2 file into musicxml via NWCtext, so it can be imported into other programs? I concur - thanks Joe.I do hope you decide to extend your project to convert to and from full spec. MusicXML files. Quote Selected
Re: Convert (from nwctxt to xml) and back (from xml to nwctxt) Reply #5 – 2009-08-13 06:41 am Dear David, Lawrie and Rich,My original motivation in coding these routines was to get nwctxt into xml, let's call it "nwcxml", so I could manipulate the nwcxml and do multistaff operations on it and return the nwcxml to nwctxt for re-import into NWC. (Whew!) Anyway I have been vaguely aware of MusicXML and I do think it would be a good idea to Quote from: Lawrie Pardy – 2009-08-12 09:28 amconvert to and from full spec. MusicXML files.I believe this could be a big undertaking based on the sigh it caused virtuoso kahman:Quote from: kahman – 2007-07-31 01:14 amAt some point, someone should write a converter to/from MXML...sigh.I have started a SourceForge open source project at https://sourceforge.net/projects/rtcnwctxt-xml/ Here is the Project Description:QuoteBASIS FOR AN OPEN SOURCE PROJECT to convert NoteWorthy Composer files from/to MusicXML. Two Python 3 programs for NoteWorthy Composer files in nwctxt format. 1. nwctxt2xml.py - Converts nwctxt into XML 2. xml2nwctxt.py - Converts XML into nwctxt Let's see if I/we can drum up some participation from others to make useful progress. By the way, I'm not sure that all musical concepts expressible in MusicXML are expressible in NWC. My intent is to have some fun with this and as I say, make useful progress. I hope all who participate will have the same outlook. Here is the MusicXML wiki page link. http://en.wikipedia.org/wiki/MusicXML And here is the MusicXML definition page from RecordCare, the driving force behind MusicXML. http://www.recordare.com/xml.htmlThanks for the interest and encouragement. Quote Selected
Re: Convert (from nwctxt to xml) and back (from xml to nwctxt) Reply #6 – 2009-08-13 07:41 am Good luck, and best wishes for success, Joe !!! Quote Selected
Re: Convert (from nwctxt to xml) and back (from xml to nwctxt) Reply #7 – 2009-08-13 09:53 am Quote from: David Palmquist – 2009-08-13 07:41 amGood luck, and best wishes for success, Joe !!!Ditto! Quote Selected
Re: Convert (from nwctxt to xml) and back (from xml to nwctxt) Reply #8 – 2009-08-13 05:29 pm Double ditto ! Send file as requested. Here's hoping Quote Selected
Re: Convert (from nwctxt to xml) and back (from xml to nwctxt) Reply #9 – 2009-08-14 02:57 pm Good luck, Joe indeed!! You should be awarded hero status. Quote Selected
Re: Convert (from nwctxt to xml) and back (from xml to nwctxt) Reply #10 – 2009-08-17 12:27 pm I had the idea to write such a converter myself some time ago, but being busy (and lazy :-) the thing didn't ever start.So, once again good luck Joe! Quote Selected
Re: Convert (from nwctxt to xml) and back (from xml to nwctxt) Reply #11 – 2009-09-15 04:14 pm Thanks for the tool you created. I am specifically looking for a tool that converts NWC files to MusicXML, so that I can import all of my old files into MuseScore.I have been a NWC fan for 10 years, but now that I have discovered MuseScore I am migrating to that tool. Reasons being that it is open source, multi-platform, and has a fairly large development team. I still wish the best of luck to the NWC team! Quote Selected
Re: Convert (from nwctxt to xml) and back (from xml to nwctxt) Reply #12 – 2009-09-17 10:45 pm Please see : https://forum.noteworthycomposer.com/?topic=6945.0 Quote Selected