Let XMLWriter add initial XML header too
Getty Ritter
6 years ago
29 | 29 | } |
30 | 30 | |
31 | 31 | impl<'a> XMLWriter<'a> { |
32 | pub fn start(buf: &'a mut Write) -> io::Result<XMLWriter<'a>> { | |
33 | writeln!(buf, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>")?; | |
34 | Ok(XMLWriter { writer: buf }) | |
35 | } | |
36 | ||
32 | 37 | /// create an entire closed tag with the given attributes |
33 | 38 | pub fn tag(&mut self, name: &str, attrs: &[(&str, &Display)]) -> io::Result<()> { |
34 | 39 | write!(self.writer, "<{}", name)?; |
119 | 124 | |
120 | 125 | pub fn write_svg<W: Write>(self, buf: &mut W) -> io::Result<()> { |
121 | 126 | let (w, h) = self.size; |
122 | writeln!(buf, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>")?; | |
123 | let mut xml = XMLWriter { writer: buf }; | |
127 | let mut xml = XMLWriter::start(buf)?; | |
124 | 128 | xml.block( |
125 | 129 | "svg", |
126 | 130 | &[("xmlns", &"http://www.w3.org/2000/svg"), |