1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*! How to serialise a tree structure.
*/

use crate::qname::QualifiedName;
use core::fmt;

/// An output definition. See XSLT v3.0 26 Serialization
#[derive(Clone, Debug)]
pub struct OutputDefinition {
    name: Option<QualifiedName>, // TODO: EQName
    indent: bool,
    // TODO: all the other myriad output parameters
}

impl Default for OutputDefinition {
    fn default() -> Self {
        Self::new()
    }
}

impl OutputDefinition {
    pub fn new() -> OutputDefinition {
        OutputDefinition {
            name: None,
            indent: false,
        }
    }
    pub fn get_name(&self) -> Option<QualifiedName> {
        self.name.clone()
    }
    pub fn set_name(&mut self, name: Option<QualifiedName>) {
        match name {
            Some(n) => {
                self.name.replace(n);
            }
            None => {
                self.name = None;
            }
        }
    }
    pub fn get_indent(&self) -> bool {
        self.indent
    }
    pub fn set_indent(&mut self, ind: bool) {
        self.indent = ind;
    }
}
impl fmt::Display for OutputDefinition {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        if self.indent {
            f.write_str("indent output")
        } else {
            f.write_str("do not indent output")
        }
    }
}