From efe4e0f1182189f18ffbf3804b90aced585c0f2a Mon Sep 17 00:00:00 2001 From: bokuweb Date: Fri, 13 Sep 2019 19:41:05 +0900 Subject: [PATCH] chore: write simple xml --- Cargo.lock | 10 ++ docx-core/Cargo.toml | 3 +- docx-core/examples/example.rs | 2 +- docx-core/fixtures/hello/[Content_Types].xml | 3 + docx-core/fixtures/hello/_rels/.rels | 3 + docx-core/fixtures/hello/docProps/app.xml | 2 + docx-core/fixtures/hello/docProps/core.xml | 2 + docx-core/fixtures/hello/hello.docx | Bin 0 -> 4132 bytes .../hello/word/_rels/document.xml.rels | 6 ++ docx-core/fixtures/hello/word/document.xml | 33 ++++++ docx-core/fixtures/hello/word/fontTable.xml | 31 ++++++ docx-core/fixtures/hello/word/settings.xml | 8 ++ docx-core/fixtures/hello/word/styles.xml | 94 ++++++++++++++++++ .../fixtures/hello_world/[Content_Types].xml | 1 + docx-core/fixtures/hello_world/_rels/.rels | 1 + .../fixtures/hello_world/docProps/app.xml | 1 + .../fixtures/hello_world/docProps/core.xml | 1 + .../fixtures/hello_world/hello_world.docx | Bin 0 -> 19663 bytes .../hello_world/word/_rels/document.xml.rels | 1 + .../hello_world/word/_rels/footer1.xml.rels | 1 + .../hello_world/word/_rels/header1.xml.rels | 1 + .../fixtures/hello_world/word/document.xml | 44 ++++++++ .../fixtures/hello_world/word/footer1.xml | 1 + .../fixtures/hello_world/word/footnotes.xml | 1 + .../fixtures/hello_world/word/header1.xml | 1 + .../fixtures/hello_world/word/numbering.xml | 1 + .../fixtures/hello_world/word/styles.xml | 1 + docx-core/src/lib.rs | 24 ++++- 28 files changed, 273 insertions(+), 4 deletions(-) create mode 100644 docx-core/fixtures/hello/[Content_Types].xml create mode 100644 docx-core/fixtures/hello/_rels/.rels create mode 100644 docx-core/fixtures/hello/docProps/app.xml create mode 100644 docx-core/fixtures/hello/docProps/core.xml create mode 100644 docx-core/fixtures/hello/hello.docx create mode 100644 docx-core/fixtures/hello/word/_rels/document.xml.rels create mode 100644 docx-core/fixtures/hello/word/document.xml create mode 100644 docx-core/fixtures/hello/word/fontTable.xml create mode 100644 docx-core/fixtures/hello/word/settings.xml create mode 100644 docx-core/fixtures/hello/word/styles.xml create mode 100644 docx-core/fixtures/hello_world/[Content_Types].xml create mode 100644 docx-core/fixtures/hello_world/_rels/.rels create mode 100644 docx-core/fixtures/hello_world/docProps/app.xml create mode 100644 docx-core/fixtures/hello_world/docProps/core.xml create mode 100644 docx-core/fixtures/hello_world/hello_world.docx create mode 100644 docx-core/fixtures/hello_world/word/_rels/document.xml.rels create mode 100644 docx-core/fixtures/hello_world/word/_rels/footer1.xml.rels create mode 100644 docx-core/fixtures/hello_world/word/_rels/header1.xml.rels create mode 100644 docx-core/fixtures/hello_world/word/document.xml create mode 100644 docx-core/fixtures/hello_world/word/footer1.xml create mode 100644 docx-core/fixtures/hello_world/word/footnotes.xml create mode 100644 docx-core/fixtures/hello_world/word/header1.xml create mode 100644 docx-core/fixtures/hello_world/word/numbering.xml create mode 100644 docx-core/fixtures/hello_world/word/styles.xml diff --git a/Cargo.lock b/Cargo.lock index 9d04b83..493ec46 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,4 +3,14 @@ [[package]] name = "docx-core" version = "0.1.0" +dependencies = [ + "xml-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", +] +[[package]] +name = "xml-rs" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[metadata] +"checksum xml-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "541b12c998c5b56aa2b4e6f18f03664eef9a4fd0a246a55594efae6cc2d964b5" diff --git a/docx-core/Cargo.toml b/docx-core/Cargo.toml index bfac336..95cfdd6 100644 --- a/docx-core/Cargo.toml +++ b/docx-core/Cargo.toml @@ -6,4 +6,5 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[dependencies] \ No newline at end of file +[dependencies] +xml-rs = "0.8.0" \ No newline at end of file diff --git a/docx-core/examples/example.rs b/docx-core/examples/example.rs index 321cc34..9a850eb 100644 --- a/docx-core/examples/example.rs +++ b/docx-core/examples/example.rs @@ -1,5 +1,5 @@ extern crate docx_core; fn main() { - println!("{}", docx_core::add_one(1)); + docx_core::simple(); } \ No newline at end of file diff --git a/docx-core/fixtures/hello/[Content_Types].xml b/docx-core/fixtures/hello/[Content_Types].xml new file mode 100644 index 0000000..dc111cb --- /dev/null +++ b/docx-core/fixtures/hello/[Content_Types].xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/docx-core/fixtures/hello/_rels/.rels b/docx-core/fixtures/hello/_rels/.rels new file mode 100644 index 0000000..f0b72e7 --- /dev/null +++ b/docx-core/fixtures/hello/_rels/.rels @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/docx-core/fixtures/hello/docProps/app.xml b/docx-core/fixtures/hello/docProps/app.xml new file mode 100644 index 0000000..f819b8e --- /dev/null +++ b/docx-core/fixtures/hello/docProps/app.xml @@ -0,0 +1,2 @@ + +0LibreOffice/6.0.7.3$Linux_X86_64 LibreOffice_project/00m0$Build-311551 \ No newline at end of file diff --git a/docx-core/fixtures/hello/docProps/core.xml b/docx-core/fixtures/hello/docProps/core.xml new file mode 100644 index 0000000..aa2d79a --- /dev/null +++ b/docx-core/fixtures/hello/docProps/core.xml @@ -0,0 +1,2 @@ + +2019-09-13T19:32:17Zja-JP2019-09-13T19:32:34Z1 \ No newline at end of file diff --git a/docx-core/fixtures/hello/hello.docx b/docx-core/fixtures/hello/hello.docx new file mode 100644 index 0000000000000000000000000000000000000000..a0c02238064548046ca67962a9f33979f250fba3 GIT binary patch literal 4132 zcmai11z6L27ak1hE@6Pu0urK>Gy*zm;7F;_NR1SvE^$Fx7%9>qqf&(ZC z{w#`CQ3A>kKHEB@lHHuOy&2p+c))zmo_QZ9AaP@JXb|U)Rnf(q41TRzXnI$@`|dXV zh~40MIwUzPOr|a0O2+ZlaP2MYr!x|K*NsN`YPBV!#uO9vx$@@%GL6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6okl2=I*4WBgmMTm}M*YRUm>vX9J z4xYSuSRdHAw~Fyre3{Iie*d1aJ`w$g?3VWifn6^wJ>KuP>+m2ukX)&=*WU8$zwEod z$==y#)Z9AcPkTk&e4T?p++AKiFA_6kpIfs!d1ux*&%;Y9^HV(k_`MkqERN(qT%RbV zUeA}8s@J&QS4h*;Wcb1B^nADN6K6gKsYS^+a~`E(ji}_8sv3ZeL&7orgctg*%g4zU!kX6l(K7wfv%NwM74%Yo`2l2i_En`;uo!v?p zsbnr_sPq?-nDxW5r3!*^Y8yH%aGT^0JDF>>ldNpuND4?;SItURVwfdjyU$FQXybr> zlJ|vCs^=Qa$dfC)?ELL+`{>-wSBFeI{NANUEXqyqGrf*yvToy{rZb$AHx z^-zmj+bFuGu5e?p6pbKxrewX749lKWa;-N2mBBWpW(K&MFP&o<2r=(`ZXQxFJ!8ad zIF1)%N|PrzWq!+7Q^D?wXBA9a$hC?0snXw!#jBbE7#l9-v5K(V>4{EqlQoN17I|mG ziMhX|mnAto5<;1hg)R1FI~*(AM+K?{uYc0bDH2v2<4|Q)fz|tzwmZ7zc{0AnItRJe zkORG*E=f)s$?N-vh<5GI;}!2~1bQw^hgm>OSjVy3T}jWa1j@1Gdb99|d%~zd{u7IN z7oDvMqW!~RY?8beZesm6{v5J6l5A}ZYO0RlcWW)dmptdo7e=$~;5xjQ=ulLcgLfyGpcK`VsahS^N+Ex6}U> ze%Xbgt>=#*LFM>6Bl_z + + + + + \ No newline at end of file diff --git a/docx-core/fixtures/hello/word/document.xml b/docx-core/fixtures/hello/word/document.xml new file mode 100644 index 0000000..775c58a --- /dev/null +++ b/docx-core/fixtures/hello/word/document.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + Hello + + + + + + + + + + + + \ No newline at end of file diff --git a/docx-core/fixtures/hello/word/fontTable.xml b/docx-core/fixtures/hello/word/fontTable.xml new file mode 100644 index 0000000..d7d5fd9 --- /dev/null +++ b/docx-core/fixtures/hello/word/fontTable.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docx-core/fixtures/hello/word/settings.xml b/docx-core/fixtures/hello/word/settings.xml new file mode 100644 index 0000000..a516ac4 --- /dev/null +++ b/docx-core/fixtures/hello/word/settings.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/docx-core/fixtures/hello/word/styles.xml b/docx-core/fixtures/hello/word/styles.xml new file mode 100644 index 0000000..d8d8049 --- /dev/null +++ b/docx-core/fixtures/hello/word/styles.xml @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docx-core/fixtures/hello_world/[Content_Types].xml b/docx-core/fixtures/hello_world/[Content_Types].xml new file mode 100644 index 0000000..9c5c964 --- /dev/null +++ b/docx-core/fixtures/hello_world/[Content_Types].xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docx-core/fixtures/hello_world/_rels/.rels b/docx-core/fixtures/hello_world/_rels/.rels new file mode 100644 index 0000000..1399e4d --- /dev/null +++ b/docx-core/fixtures/hello_world/_rels/.rels @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docx-core/fixtures/hello_world/docProps/app.xml b/docx-core/fixtures/hello_world/docProps/app.xml new file mode 100644 index 0000000..8993710 --- /dev/null +++ b/docx-core/fixtures/hello_world/docProps/app.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docx-core/fixtures/hello_world/docProps/core.xml b/docx-core/fixtures/hello_world/docProps/core.xml new file mode 100644 index 0000000..3f8b481 --- /dev/null +++ b/docx-core/fixtures/hello_world/docProps/core.xml @@ -0,0 +1 @@ +Un-namedUn-named12019-09-13T19:25:28Z2019-09-13T19:25:28Z \ No newline at end of file diff --git a/docx-core/fixtures/hello_world/hello_world.docx b/docx-core/fixtures/hello_world/hello_world.docx new file mode 100644 index 0000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Uy zsiE2_%xRwTf5hB--)Mg71dAEEJ_pTxZx^S}uv_ycEx?jDC^FsRw-?M8*n(U;C31+t zrFR&UCrAhR!7*Svxw zIoKOy#ctIpR4^-6me~@r7@HzzmDSM8m_i7gkxcL7bjo&1?2~37k|D*%&X&5Xl_QaR zs%E8_mr~7NkP+37#u=kh%ayC#OSWxvOT{8~HXGVnwq7nu#*wAnO3d)YL{_bq)*mrD zykIe9CPIJ3?YFsTByP^GA?Qz@eCn&$o@zAc%FdP* zEQnTB%HS3$p2gZ~v9?;Qtqiwx>hDXKKMyg-ZzyOk2fLdT&0{N$(Hj#uG>qL~{!)8e z?1e_!>8cvvk|3(`Tz-5=?*OZ9);;M9^|xKPth zj#ezmx0wqBiG(7asf(6EZZPJ7`Jt&gaq#Z{Pji(*b6w4@sn#fZL#dQD<{rED`Nr%Y zCPI9G4}}Tz;US@kV*XH(0Hyz5Q7HQI!bCTJxFAP=fL}i1E#^xC6FCQNH0XT@@ga6M zzNkeuCYt$vghIqNqmD+a1`0Gybo0=9j{Y=~Cgr%<#LwZy-lixM*Q2jVe6=N7>>cxz zLQd$NBBHKvo)9^W1=@lYA7bI(Uss#0CXTr!tFRi4R$JjzHfHXz<%mD)NO`qj+HBTL zjpx|Uu1ajOXBP9VXcOB^8s*r(-YDo=bWQt@4 s@Hv4We^WDh8P1#7W>lPGvzwYa`65gh{}bFmp2eF)Eo_p$dxtRo3oSLd!2kdN literal 0 HcmV?d00001 diff --git a/docx-core/fixtures/hello_world/word/_rels/document.xml.rels b/docx-core/fixtures/hello_world/word/_rels/document.xml.rels new file mode 100644 index 0000000..05a042b --- /dev/null +++ b/docx-core/fixtures/hello_world/word/_rels/document.xml.rels @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docx-core/fixtures/hello_world/word/_rels/footer1.xml.rels b/docx-core/fixtures/hello_world/word/_rels/footer1.xml.rels new file mode 100644 index 0000000..7b81324 --- /dev/null +++ b/docx-core/fixtures/hello_world/word/_rels/footer1.xml.rels @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docx-core/fixtures/hello_world/word/_rels/header1.xml.rels b/docx-core/fixtures/hello_world/word/_rels/header1.xml.rels new file mode 100644 index 0000000..7b81324 --- /dev/null +++ b/docx-core/fixtures/hello_world/word/_rels/header1.xml.rels @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docx-core/fixtures/hello_world/word/document.xml b/docx-core/fixtures/hello_world/word/document.xml new file mode 100644 index 0000000..9d20cc4 --- /dev/null +++ b/docx-core/fixtures/hello_world/word/document.xml @@ -0,0 +1,44 @@ + + + + + + + + + Hello World + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docx-core/fixtures/hello_world/word/footer1.xml b/docx-core/fixtures/hello_world/word/footer1.xml new file mode 100644 index 0000000..05a9751 --- /dev/null +++ b/docx-core/fixtures/hello_world/word/footer1.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docx-core/fixtures/hello_world/word/footnotes.xml b/docx-core/fixtures/hello_world/word/footnotes.xml new file mode 100644 index 0000000..edbd2f4 --- /dev/null +++ b/docx-core/fixtures/hello_world/word/footnotes.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docx-core/fixtures/hello_world/word/header1.xml b/docx-core/fixtures/hello_world/word/header1.xml new file mode 100644 index 0000000..08805f3 --- /dev/null +++ b/docx-core/fixtures/hello_world/word/header1.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docx-core/fixtures/hello_world/word/numbering.xml b/docx-core/fixtures/hello_world/word/numbering.xml new file mode 100644 index 0000000..0f46501 --- /dev/null +++ b/docx-core/fixtures/hello_world/word/numbering.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docx-core/fixtures/hello_world/word/styles.xml b/docx-core/fixtures/hello_world/word/styles.xml new file mode 100644 index 0000000..c9a6343 --- /dev/null +++ b/docx-core/fixtures/hello_world/word/styles.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docx-core/src/lib.rs b/docx-core/src/lib.rs index 00ede4f..9aad3cf 100644 --- a/docx-core/src/lib.rs +++ b/docx-core/src/lib.rs @@ -1,4 +1,24 @@ +use std::fs::File; +use std::io::{self, Write}; -pub fn add_one(x: i32) -> i32 { - x + 1 +use xml::writer::{EmitterConfig, EventWriter, Result, XmlEvent}; + +pub fn simple() { + let mut file = File::create("./dist/output.xml").unwrap(); + let mut b = Vec::new(); + let mut w = EmitterConfig::new() + .write_document_declaration(false) + .create_writer(&mut b); + + w.write(XmlEvent::start_element("h:hello").ns("h", "urn:hello-world")) + .unwrap(); + w.write("hello world").unwrap(); + w.write(XmlEvent::end_element()).unwrap(); + + file.write_all(&b).unwrap(); + file.flush().unwrap(); + // assert_eq!( + // str::from_utf8(&b).unwrap(), + // r#"hello world"# + // ); }