-
-
Notifications
You must be signed in to change notification settings - Fork 114
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
No way to emit doctype when writing an XML file #168
Comments
As I see it, changes in parsing and writing should be symmetric, because the respective data structures (writer::XmlEvent and reader::XmlEvent) are supposed to be convertible to each other. For now, I've implemented the |
It's easy enough to write the doctype element using the |
The 'characters' writer event could not be used to output text after the document declaration, only before it or after the first XML element. This change ensures that the document declaration will be output before the text. Arbitrary text can still be output at the start of the file, if needed, by writing directly using the inner_mut method. Addresses issue netvl#168.
I've pushed a one-line change that causes the document declaration to be output before any text is output using the |
Fix issue #168: Force XML document declaration to be output before 'characters' event
@brackleian your change is released in 0.8.4. Unfortunately I don't think I'll be able to work on solving the entire issue, since I don't have capacity to work on xml-rs anymore. |
Hi Vladimir,
On Wed, 28 Jul 2021 21:10:02 -0700 Vladimir Matveev ***@***.***> wrote:
@brackleian your change is released in 0.8.4. Unfortunately I don't think I'll be able to work on solving the entire issue, since I don't have capacity to work on xml-rs anymore.
Many thanks for that, 0.8.4 works well.
So you won't mind if I hack around with it some more, to try and get a better fix? :)
Cheers,
Austin.
|
@brackleian I don't mind, but unfortunately I can't tell when I'll be able to take a look at any changes and merge them. Overall, I feel that a better rewrite of the whole thing is needed, and that's what I started in one of the branches, but it is clear to me that I won't be able to finish it in foreseeable future. |
Should a note in the README be added about how to add the doctype declaration? I am doing as follows. let mut w = EventWriter::new(file);
w.write(XmlEvent::StartDocument {
version: xml::common::XmlVersion::Version10,
encoding: Some("UTF-8"),
standalone: Some(false),
})?;
write!(w.inner_mut(), "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">")?; |
There doesn't appear to be any way to emit a doctype when writing an XML file.
XmlEvent
doesn't contain any way to represent one. This is a problem for me.#133 talks about supporting doctypes already, but that's from the perspective of parsing. Adding support for emitting them should be a lot simpler.
The text was updated successfully, but these errors were encountered: