snoyberg/xml

XML Canonicalisation

ljdarj opened this issue · 3 comments

For something I'm working on I need to output canonicalised XML.

I'm willing to implement a RenderSetting to optionally canonicalise the XML output, would you take such a pull request?

I'd defer to @k0ral on whether this should be added. But I'm curious: what does canonicalized mean here? What's the difference from what is currently rendered?

That's the canonicalisation from here, which in short defines a standard order for attributes, requires that CDATA sections be replaced by their textual content and a few other things.

But thinking of it, a separate function — and not necessarily in xml-conduit at that — would probably be a better fit rather than piggy-backing on renderText & co: canonicalisation can fail contrary to renderText & co.

k0ral commented

I've skimmed through the "Canonical XML" specification, and I have the feeling this could fit nicely in xml-conduit, for example as an alternate implementation of the tokenToBuilder function.

The fact that canonicalisation can fail doesn't strike me as a blocker -- the signatures of the new functions just need to convey that possibility.

Just my 2 cents though, I might not realize that this is harder than it looks.