|
@@ -29,6 +29,11 @@ pub struct XMLWriter<'a>{
|
|
|
}
|
|
|
|
|
|
impl<'a> XMLWriter<'a> {
|
|
|
+ pub fn start(buf: &'a mut Write) -> io::Result<XMLWriter<'a>> {
|
|
|
+ writeln!(buf, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>")?;
|
|
|
+ Ok(XMLWriter { writer: buf })
|
|
|
+ }
|
|
|
+
|
|
|
/// create an entire closed tag with the given attributes
|
|
|
pub fn tag(&mut self, name: &str, attrs: &[(&str, &Display)]) -> io::Result<()> {
|
|
|
write!(self.writer, "<{}", name)?;
|
|
@@ -119,8 +124,7 @@ impl SVG {
|
|
|
|
|
|
pub fn write_svg<W: Write>(self, buf: &mut W) -> io::Result<()> {
|
|
|
let (w, h) = self.size;
|
|
|
- writeln!(buf, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>")?;
|
|
|
- let mut xml = XMLWriter { writer: buf };
|
|
|
+ let mut xml = XMLWriter::start(buf)?;
|
|
|
xml.block(
|
|
|
"svg",
|
|
|
&[("xmlns", &"http://www.w3.org/2000/svg"),
|