cwrc / CWRC-WriterBase

The base class from which to create a CWRC-Writer XML editor.
GNU General Public License v2.0
14 stars 3 forks source link

Saving a document changes the reference schema (URL). #215

Open lucaju opened 4 years ago

lucaju commented 4 years ago

Expected Behaviour

The original schema reference (URL) for the document must be preserved during the saving process. Unless the user actively changes the schema on the setting panel.

Current Behaviour

The schema reference (URL) is replaced in the document for the one CRWC-Writer is able to load during the XML2CWRC process. Image one shows the original reference on the file before passing through CRWC. Image two shows that not only the reference changed, but it added the proxy URL as well.

This bug was introduced by the recent changes in the way CWRC-Writer loads schemas.

Possible Solution

Store the original schema URL while editing a document. Restore it to the file when saving. Change the stored URL if the user selects a different schema on the settings panel.

Steps to Reproduce (for bugs)

  1. Open a document that uses a secondary schema URL. E.g., for CWRC Basic TEI Schema, the secondary URL reference is https://raw.githubusercontent.com/cwrc/CWRC-Schema/master/schemas/cwrc_tei_lite.rng
  2. Save the file.

Your Environment

Screen Shot 2019-12-04 at 3.23.06 PM.png

ajmacdonald commented 4 years ago

8c471e28618154146033bcbbc4f82d4d567e002a

ilovan commented 4 years ago

confirmed on dev-cwrc-writer, but also adding <?xml-stylesheet type="text/css" href="undefined"?> to the document if no css defined; see https://dev-cwrc-writer.cwrc.ca/?githubPath=issues%2FCWRC-WriterBase%2F215&githubRepo=ilovan%2FGit-Writer-tests; is it necessary, @ajmacdonald ? It may be related to https://github.com/cwrc/CWRC-WriterBase/issues/216

ajmacdonald commented 4 years ago

So if no CSS is specified in the loaded document, then none should be added when it's saved. What about during the editing process?

ilovan commented 4 years ago

I am a bit torn. On one hand, it makes sense not to "deceive" the user by applying processing instructions that are not there, on the other I can see the benefits for readability of temporarily applying a css while the document is being edited.

Could we do what we do with the schema? [If the schema declared can't be read, then we ask if it's OK for CWRC_Writer to try to guess a schema and then apply TEI by default for all the docs that have TEI as the root element.

We could do the same with the CSS

Document load process could go something like this:

  1. check that schema declared can be read, and matches the root element
    • if YES, then proceed to check for CSS; if no css declared, popup that says so and asks if the user wants to temporarily attach a css for readability - yes/no
    • in NO, then proceed to the schema detection popup, then check from css

wdyt, @SusanBrown

SusanBrown commented 4 years ago

I agree--sounds like a good way to go.