ganttproject icon indicating copy to clipboard operation
ganttproject copied to clipboard

Don't remove non-CDATA notes

Open ghost opened this issue 5 years ago • 2 comments

When a *.gan file is modified by an external programm (I use xmlstarlet to sync gitlab milestones to the project file), it might or might not use `' blocks when not required by the XML spec. Currently GanttProject discards (removes!) such entries.

Reproduce:

  1. Add a task with a note, e.g. <notes><![CDATA[sample note with cdata]]></notes>
  2. Update note, e.g. by xmlstarlet ed -L -u '///notes' -v 'updated note' cdata.gan
  3. Open file: Note is not shown
  4. When changes are saved, the note gets removed from the data.

Workaround:

Use transformation with cdata-section-elements="notes description"

ghost avatar Mar 05 '20 15:03 ghost

We use standard XML API which is built into Java Runtime and where text inside element is supposed to be CDATA, there is no other option, at least with javax.xml.transform API. Even if there was an option, we would not use it because of compatibility with the older GanttProject versions.

We overwrite the whole file on write and we're not going to invest into fragile process of merging files.

We might consider trying to parse notes without CDATA, but shall we really invest into it when you can just add text() to your XPath expression in xmlstarlet command line? This works fine for me and preserves CDATA perfectly:

xmlstarlet ed -L -u '///notes/text()' -v 'updated note' cdata.gan

dbarashev avatar Mar 05 '20 15:03 dbarashev

Thanks for pointing '///notes/text()' out to me. This fixes my needs. I still think non-cdata blocks would be nice, but definitely not a bug or deal breaker. Feel free to close or tag as low priority.

Edit: This only works for updates, not for inserts. So I recommend keeping this ticket. For now I use the xsl transformation from above.

ghost avatar Mar 05 '20 16:03 ghost