ebarnard / rust-plist

A rusty plist parser.
MIT License
71 stars 42 forks source link

XML output does not include DOCTYPE #26

Closed lilyball closed 6 years ago

lilyball commented 6 years ago

A proper plist includes a DOCTYPE

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

The output from this crates does not include this doctype.

Also, less importantly, the output from Apple's plist code capitalizes the encoding name, i.e.

<?xml version="1.0" encoding="UTF-8"?>

but the output from this crate lowercases it.

lilyball commented 6 years ago

Apple's plist code also doesn't indent the child of the <plist> tag.

Ultimately, I'd like to be able to deserialize a plist created from Apple's tools, and then reserialize it, and end up with the exact same file (modulo dictionary key order).

lilyball commented 6 years ago

It appears as though Apple's code also indents using hard tabs.

lilyball commented 6 years ago

I looked into implementing the DOCTYPE part myself and it doesn't really appear doable with xml-rs. I filed https://github.com/netvl/xml-rs/issues/168 on their end, but in the meantime it looks like the only way to do this is to write out the raw text to the writer prior to constructing the XmlWriter for it. The downside here is it means we would write to the writer immediately in EventWriter::new(), which is fairly odd. Alternatively we could replace the writer with an enum to represent the "we haven't written anything yet" state, but it seems kind of gross.