-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
XML Prolog is omitted in saved file #1163
Comments
I think this is because the XML prolog is not XML, strictly speaking. It has to be added in a different way, this seemed helpful to me: https://stackoverflow.com/questions/50109538/altering-an-existing-xml-prolog-with-javascript |
It is quite obscure but it is not the way the prolog is formed:
So it seems to be narrowing it down to something related to what happens in "Import IEDs" I put a breakpoint on L440 before the action to import the IED occurred, and imported both IEDs. open-scd/src/menu/ImportIEDs.ts Lines 433 to 445 in e22e42d
Before I get:
after I get:
I wonder if the new editing API has a similar problem, I'll look to see exactly where the breakage occurs in some time. |
Suggestion: maybe we can add an automated test to this in order to see if the behavior is correct. |
I think the core problem resides in the action API. I'm not sure how best to diagnose it. This would prevent further work on the old API: export default class SaveProjectPlugin extends LitElement {
async run() {
if (this.doc) {
// at prolog if it's been stripped
if (this.doc.xmlEncoding === null) {
const pi = this.doc.createProcessingInstruction(
'xml',
'version="1.0" encoding="UTF-8"'
);
this.doc.insertBefore(pi, this.doc.firstChild);
} If this is acceptable I can do a PR. |
We decided to see if progress in using the new edit action API will resolve this in a short time (next couple of weeks). The root cause is that at the moment in the action API we instantiate a new document constantly without adding the prolog (thanks @ca-d): Lines 427 to 435 in e22e42d
This was broken about 4-6 months ago as part of improving the update cycle for plugins. |
I'm currently in favor of this solution as a quick fix, since technical questions have come up for tomorrow's refinement which bear on our edit action migration timeline. If you could find the time to submit it after all, I'd try to review it as quickly as possible. Thank you! |
Ensure XML declaration is present on save, part of #1163 --------- Co-authored-by: cad <christian.dinkel@omicronenergy.com>
Hello there, Thank you for opening this issue! We appreciate your interest in our project. If you believe this issue is still relevant and requires attention, please provide any additional context, updates, or details that might help us understand the problem better. If the issue is no longer relevant, you can simply close it. If you're uncertain, you can always reopen it later. Remember, our project thrives on community contributions, and your input matters. We're here to collaborate and improve. |
We contemplate the benefits of having bots make people work. This issue is still here even though the underlying issue is now resolved because the "workaround" code which ensures the prolog is there should be removed as it is most likely just cruft at this point. I think this means #1173 could be reverted and a few tests would be required to see this issue was still resolved. |
@danyill is this issue still relevant ? |
Well.... maybe. I guess it's still relevant as the Save plugin works around the issue that the Action API throws away the prolog which could cause issues with any other tool which saves or modifies XML files. Once the Action API is gone then the issue will be resolved as I don't believe it occurs with the newer APIs. So we could close it because we have an upgrade path that will resolve it naturally or we could leave it open until that is done (my preference). |
Describe the bug
When importing an ICD and an IID file into a new Edition 2 project and then saving, the XML prolog is omitted (this caused the GE Enervista software to crash). We think it is also non-compliant with Part 6, Ed 2.1, section 8.4.
To Reproduce
Steps to reproduce the behavior:
B30 (1).zip
Expected behavior
The XML prolog is always included:
Also
This doesn't seem to be related to the input files but rather the way we instantiate a "New Project".
The code looks like it supports the XML prolog, but perhaps it is not sufficient to generate it from a string?
In the Communication Export plugin I did:
Which seems to generate the correct prolog.
The text was updated successfully, but these errors were encountered: