This commit is contained in:
Able 2023-03-30 23:25:47 -05:00
parent f8575ec041
commit 0971ef1260
6 changed files with 93 additions and 1 deletions

20
Cargo.lock generated
View file

@ -330,6 +330,12 @@ dependencies = [
"versioning",
]
[[package]]
name = "simple_xml_serialize"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f8896c3696f051907ae5e59f0c2d9fb9f7521c29d636e4a1ea4ff0e4e5aac15"
[[package]]
name = "std"
version = "0.1.0"
@ -478,3 +484,17 @@ version = "0.1.0"
dependencies = [
"logos",
]
[[package]]
name = "xml-builder"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efc4f1a86af7800dfc4056c7833648ea4515ae21502060b5c98114d828f5333b"
[[package]]
name = "xml_tests"
version = "0.1.0"
dependencies = [
"simple_xml_serialize",
"xml-builder",
]

View file

@ -35,7 +35,7 @@ members = [
"programs/table_view",
"programs/undelete",
"programs/wat2wasm",
"programs/xml_tests",
"programs/std_test",
]

View file

@ -0,0 +1,5 @@
<mouse last_updated="10:10:15.204">
<left_button pressed="True" just_pressed="False"/>
<right_button pressed="False" just_pressed="False"/>
<position x="0" y="0" x_change="-3" y_change="10"/>
</mouse>

View file

@ -56,3 +56,32 @@ pub struct ExiHeader {
}
pub struct ExiDocument {}
impl ExiDocument {
pub fn new_from_xml(xml_string: String) -> Self {
println!("{}", xml_string);
Self {}
}
}
#[cfg(unix)]
mod unix {
use std::{
fs::{self, File},
io::Read,
path::Path,
};
use crate::ExiDocument;
fn parse_exi_from_file(path: &Path) -> ExiDocument {
let file_contents = fs::read_to_string(path).unwrap();
ExiDocument::new_from_xml(file_contents)
// ExiDocument {}
}
#[test]
fn test_xml_to_exi() {
parse_exi_from_file(Path::new(
"/home/able/Projects/ableos_userland/libraries/exi/assets/sample.xml",
));
}
}

View file

@ -0,0 +1,10 @@
[package]
name = "xml_tests"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
simple_xml_serialize = "*"
xml-builder = "0.5.2"

View file

@ -0,0 +1,28 @@
// use simple_xml_serialize::XMLElement;
// fn main() {
// let mut ele = XMLElement::new("mouse");
// println!("{}", ele);
// }
use xml_builder::{XMLBuilder, XMLElement, XMLVersion};
fn main() {
let mut xml = XMLBuilder::new()
.version(XMLVersion::XML1_1)
.encoding("UTF-8".into())
.build();
let mut mouse = XMLElement::new("mouse");
mouse.add_attribute("x", "8");
mouse.add_attribute("y", "0");
mouse.add_attribute("y_change", "-1");
mouse.add_attribute("x_change", "1");
xml.set_root_element(mouse);
let mut writer: Vec<u8> = Vec::new();
xml.generate(&mut writer).unwrap();
println!("{}", String::from_utf8_lossy(&writer));
}