Skip to content
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

Ouput XML in canonical form #289

Open
MichaelClerx opened this issue Mar 22, 2019 · 9 comments
Open

Ouput XML in canonical form #289

MichaelClerx opened this issue Mar 22, 2019 · 9 comments
Labels
New feature Additional feature

Comments

@MichaelClerx
Copy link
Contributor

Hi all!

Working in london with XML expert @jonc125 today, who told me something very relevant to yesterdays discussion on XML output:

  1. There is a standard (of course there is) that defines canonical XML serialisation: https://www.w3.org/TR/xml-c14n11/
  2. LibXML2 has support for this: http:https://xmlsoft.org/html/libxml-c14n.html

So should be an easy fix?

@MichaelClerx
Copy link
Contributor Author

I think we'd still have to define some extra rules though, like sorting components and variables etc. by name

@hsorby
Copy link
Contributor

hsorby commented Mar 22, 2019

The TR states this

  • Lexicographic order is imposed on the namespace declarations and attributes of each element

So that part is covered. But nothing on element ordering as far as I can see.

It appears that you can choose to have comments in or out for this form. Where do we sit on this comments situation?

I think @agarny would be saying comments in. Comment locations would require tracking or attaching to some point. Could we exclude some comments and only support comments between elements?

@agarny
Copy link
Contributor

agarny commented Mar 22, 2019

Canonical XML serialisation seems like what we might be after. Nice!

I had a (very) quick look at the TR and I couldn't see anything about element ordering. It looks like the same order is used between the input document and its canonical form, which I am happy with.

When it comes to comments, I would indeed want us to have a commented canonical form. @hsorby, OpenCOR only generates comments between elements, so I would personally be happy with just those (see here and here for some tests that cover OpenCOR's support of comments).

@MichaelClerx
Copy link
Contributor Author

When it comes to element ordering, I think it won't be in the TR as you're allowed to have meaningful ordering in XML documents (for example a <ol> in XHTML). So we'd have to add some additional rules for that.

I agree comments would be nice! Maybe a long term thing though? Sounds to me like if we fix this we might as well fix the whitespace thing. So I'm guessing we keep some sort of record of where everything was, and how much whitespace/comments came before/after it?

Maybe good to split that into a different ticket?

@nickerso
Copy link
Contributor

discussion on previous issues likely also relevant, e.g., #45 (comment)

@MichaelClerx
Copy link
Contributor Author

Just thinking about this from a different angle: When importing most cardiac models I get the state variables in the same order as the paper uses (e.g. with V as the first variable). That would be destroyed by a canonical ordering scheme.

@MichaelClerx
Copy link
Contributor Author

Thinking a bit more on that, if your model has component.variable pairs like a.x, a.z, and b.y and you want the states ordered as a.x, b.y, a.z then there's no way to achieve this via ordering the elements in the cellml doc

@MichaelClerx
Copy link
Contributor Author

Thinking a bit more on that, if your model has component.variable pairs like a.x, a.z, and b.y and you want the states ordered as a.x, b.y, a.z then there's no way to achieve this via ordering the elements in the cellml doc

(I can't think of a use-case for that, but it just means that getting the order from the order in the doc, which is meaningless according to the spec anyway, shouldn't be the way to go)

@MichaelClerx
Copy link
Contributor Author

Couple of things I don't love about canonical form: https://en.wikipedia.org/wiki/Canonicalization#XML

  • xml header is removed
  • empty elements are writen like
  • default attributes are writen explicitly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New feature Additional feature
Projects
None yet
Development

No branches or pull requests

4 participants