appendix.texi (10232B)
1 @anchor{xml_schema} 2 @appendix XML schema 3 4 @example 5 <xs:schema xmlns:xs = "http://www.w3.org/2001/XMLSchema" 6 targetNamespace = "http://usawa.defalsify.org/" 7 xmlns = "http://usawa.defalsify.org/" 8 elementFormDefault = "qualified"> 9 10 <xs:element name="ledger"> 11 <xs:complexType> 12 <xs:sequence> 13 <xs:element name="topic" type="xs:string" /> 14 <xs:element name="generated" type="xs:dateTime" /> 15 <xs:element name="src" type="xs:string" /> 16 <xs:element name="units" type="Units" /> 17 <xs:element name="resolver" type="Resolver" minOccurs="0" maxOccurs="unbounded" /> 18 <xs:element name="identity" type="Identity" minOccurs="1" maxOccurs="unbounded" /> 19 <xs:element name="incoming" type="Incoming" minOccurs="0" maxOccurs="1" /> 20 <xs:element name="entry" type="Entry" minOccurs="0" maxOccurs="unbounded" /> 21 </xs:sequence> 22 <xs:attribute name="version" type="xs:integer" /> 23 <xs:attribute name="uuid" type="xs:string" /> 24 </xs:complexType> 25 </xs:element> 26 27 <xs:complexType name="Incoming"> 28 <xs:sequence> 29 <xs:element name="real" type="Balance" minOccurs="1" maxOccurs="unbounded" /> 30 <xs:element name="virt" type="Balance" minOccurs="0" maxOccurs="unbounded" /> 31 <xs:element name="digest" type="Digest" minOccurs="1" maxOccurs="1"/> 32 <xs:element name="sig" type="Signature" minOccurs="1" maxOccurs="unbounded" /> 33 </xs:sequence> 34 <xs:attribute name="serial" type="xs:nonNegativeInteger" /> 35 </xs:complexType> 36 37 <xs:complexType name="Balance"> 38 <xs:sequence> 39 <xs:element name="income" type="xs:integer" minOccurs="0"/> 40 <xs:element name="expense" type="xs:integer" minOccurs="0" /> 41 <xs:element name="asset" type="xs:integer" /> 42 <xs:element name="liability" type="xs:integer" /> 43 </xs:sequence> 44 <xs:attribute name="unit" type="xs:string" /> 45 </xs:complexType> 46 47 <xs:complexType name="Units"> 48 <xs:sequence> 49 <xs:element name="unit" type="Unit" minOccurs="1" maxOccurs="unbounded" /> 50 </xs:sequence> 51 <xs:attribute name="base" type="xs:string" /> 52 </xs:complexType> 53 54 <xs:complexType name="Lookup"> 55 <xs:simpleContent> 56 <xs:extension base="xs:string"> 57 <xs:attribute name="method" type="xs:string" /> 58 </xs:extension> 59 </xs:simpleContent> 60 </xs:complexType> 61 62 <xs:complexType name="Digest"> 63 <xs:simpleContent> 64 <xs:extension base="xs:string"> 65 <xs:attribute name="algo" type="xs:string" /> 66 </xs:extension> 67 </xs:simpleContent> 68 </xs:complexType> 69 70 71 <xs:complexType name="Signature"> 72 <xs:simpleContent> 73 <xs:extension base="xs:string"> 74 <xs:attribute name="keyid" type="xs:string" /> 75 <xs:attribute name="type" type="xs:string" /> 76 </xs:extension> 77 </xs:simpleContent> 78 </xs:complexType> 79 80 <xs:complexType name="Unit"> 81 <xs:sequence> 82 <xs:element name="precision" type="xs:positiveInteger" maxOccurs="1" minOccurs="1" /> 83 <xs:choice> 84 <xs:element name="exchange" type="xs:positiveInteger" maxOccurs="1" minOccurs="1" /> 85 <xs:sequence> 86 <xs:element name="rate" type="Rate" minOccurs="1" maxOccurs="unbounded" /> 87 </xs:sequence> 88 </xs:choice> 89 </xs:sequence> 90 <xs:attribute name="sym" type="xs:string" /> 91 </xs:complexType> 92 93 <xs:complexType name="Rate"> 94 <xs:sequence> 95 <xs:choice> 96 <xs:element name="at" type="xs:date" /> 97 <xs:element name="at" type="xs:dateTime" /> 98 </xs:choice> 99 <xs:element name="vs" type="xs:string" /> 100 <xs:element name="value" type="xs:integer" /> 101 </xs:sequence> 102 </xs:complexType> 103 104 <xs:complexType name="Permission"> 105 <xs:simpleContent> 106 <xs:extension base="xs:string"> 107 <xs:attribute name="flag" type="xs:positiveInteger" /> 108 </xs:extension> 109 </xs:simpleContent> 110 111 </xs:complexType> 112 <xs:complexType name="Identity"> 113 <xs:sequence> 114 <xs:element name="trust" type="Permission" minOccurs="0" maxOccurs="unbounded" /> 115 </xs:sequence> 116 <xs:attribute name="keyid" type="xs:string" /> 117 <xs:attribute name="didtype" type="xs:string" /> 118 </xs:complexType> 119 120 <xs:complexType name="Resolver"> 121 <xs:simpleContent> 122 <xs:extension base="xs:string"> 123 <xs:attribute name="algo" type="xs:string" /> 124 <xs:attribute name="proto" type="xs:string" /> 125 </xs:extension> 126 </xs:simpleContent> 127 </xs:complexType> 128 129 <xs:complexType name="Entry"> 130 <xs:sequence> 131 <xs:element name="data" type="EntryData" /> 132 <xs:element name="sig" type="Signature" minOccurs="1" maxOccurs="unbounded" /> 133 </xs:sequence> 134 <xs:attribute name="uuid" type="xs:string" /> 135 </xs:complexType> 136 137 <xs:complexType name="EntryData"> 138 <xs:sequence> 139 <xs:element name="parent" type="xs:string" /> 140 <xs:element name="ref" type="xs:string" /> 141 <xs:element name="serial" type="xs:positiveInteger" /> 142 <xs:element name="date" type="xs:date" /> 143 <xs:element name="dateTimeRegistered" type="xs:dateTime" /> 144 <xs:element name="debit" type="EntryPart" minOccurs="1" maxOccurs="unbounded" /> 145 <xs:element name="credit" type="EntryPart" minOccurs="1" maxOccurs="unbounded" /> 146 <xs:element name="attachment" type="Attachment" minOccurs="0" maxOccurs="unbounded" /> 147 </xs:sequence> 148 </xs:complexType> 149 150 <xs:complexType name="EntryPart"> 151 <xs:sequence> 152 <xs:element name="unit" type="xs:string" /> 153 <xs:element name="account" type="xs:string" /> 154 <xs:element name="amount" type="xs:nonNegativeInteger" /> 155 </xs:sequence> 156 <xs:attribute name="type" type="accountType" /> 157 </xs:complexType> 158 159 <xs:complexType name="Attachment"> 160 <xs:sequence> 161 <xs:element name="digest" type="Digest" /> 162 <xs:element name="extref" type="xs:string" minOccurs="0" maxOccurs="1" /> 163 <xs:element name="filename" type="xs:string" minOccurs="0" maxOccurs="1" /> 164 <xs:element name="description" type="xs:string" minOccurs="0" maxOccurs="1" /> 165 <xs:element name="lookup" type="Lookup" minOccurs="0" maxOccurs="unbounded" /> 166 <xs:element name="sig" type="Signature" minOccurs="0" maxOccurs="unbounded" /> 167 </xs:sequence> 168 <xs:attribute name="mime" type="xs:string" /> 169 <xs:attribute name="uuid" type="xs:string" /> 170 </xs:complexType> 171 172 <xs:simpleType name="accountType" final="restriction"> 173 <xs:restriction base="xs:string"> 174 <xs:enumeration value="income" /> 175 <xs:enumeration value="expense" /> 176 <xs:enumeration value="asset" /> 177 <xs:enumeration value="liability" /> 178 </xs:restriction> 179 </xs:simpleType> 180 </xs:schema> 181 @end example 182 183 @anchor{xml_example} 184 @appendix Example XML 185 186 The two following examples are of the same ledger, containing two entries. 187 188 The first displays header and entries from the initial (zero) state. It lists two entries. 189 190 The second displays header and entries for the ledger state after the first entry added. It lists one entry. 191 192 The third displays header for the ledger state after last entry added. It lists zero entries. 193 194 195 @section Ledger from initial state 196 197 @example 198 <?xml version="1.0"?> 199 <ledger xmlns="http://usawa.defalsify.org/" version="1"> 200 <topic>66a739edb189684585bde211f9c29f3a47616584cbe82175f88cb4a6329f9748aea04553db62e5b1bfbd7d121356e91fe2c6142a3d2ec9664099d0be203b87e4</topic> 201 <generated>2026-02-14T09:55:37Z</generated> 202 <src>defalsify.org</src> 203 <units base="BTC"> 204 <unit sym="BTC"> 205 <precision>2</precision> 206 <exchange>1000000000</exchange> 207 </unit> 208 </units> 209 <identity keyid="3b54648d60bb8a5b9e84fa0057f79b3a5996e511682e80176dc948dcbff5a4fc" didtype="usawa"/> 210 <incoming serial="0"> 211 <real unit="BTC"> 212 <income>13370000</income> 213 <expense>421300</expense> 214 <asset>13370000</asset> 215 <liability>421300</liability> 216 </real> 217 <digest algo="sha512">00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</digest> 218 <sig keyid="3b54648d60bb8a5b9e84fa0057f79b3a5996e511682e80176dc948dcbff5a4fc" type="ed25519">5f05a6c2d7f9b9f9a391ef6d6ea45baf813f1cead8aa647b6168b855d8300ed8e99c952142e08e8ac34ba5680e49ae1eabb98881f62429ec785f2057ff08b809</sig> 219 </incoming> 220 <entry> 221 <data> 222 <parent>00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</parent> 223 <ref>6b4fb8cf-ae86-42c4-a51e-fe344a25c4ea</ref> 224 <serial>1</serial> 225 <date>2026-02-14</date> 226 <dateTimeRegistered>2026-02-14T09:09:31Z</dateTimeRegistered> 227 <description>Foobar</description> 228 <debit type="income"> 229 <unit>BTC</unit> 230 <account>general</account> 231 <amount>-13370000</amount> 232 </debit> 233 <credit type="asset"> 234 <unit>BTC</unit> 235 <account>general</account> 236 <amount>13370000</amount> 237 </credit> 238 <attachment mime="application/xml" uuid="b221358b-c6b8-433c-8ea2-14b5cb282f15"> 239 <digest algo="sha256">77473684a53bd344add4f55f66432e56955a134dda637e3021f4f2592ffe717b</digest> 240 <filename>test.xml</filename> 241 </attachment> 242 <attachment mime="text/plain" uuid="cb3f94e9-98d9-4f2a-9ff6-86e32ec02148"> 243 <digest algo="sha256">fb981668c18a279e285fc4d83fba1e836cc84dd4daa73c9697d3cfd2d8aca6e0</digest> 244 <filename>LICENSE</filename> 245 </attachment> 246 </data> 247 <sig type="ed25519" keyid="3b54648d60bb8a5b9e84fa0057f79b3a5996e511682e80176dc948dcbff5a4fc">f2a099adf8f5c8da17a4ddc0c3e65fc4f868da2c038691ff01311ce3018e7a65c7090fb2e312a283340b75f7c821134a3613c890c52f27c956a51010cf8d1b06</sig> 248 </entry> 249 <entry> 250 <data> 251 <parent>d2ec3d9132d40ce747a66049921fe864907e8ed8730d289a4c54bfcd6a9b8f3adcdead00f5c03cf4f5348fde609254461b16c78e1b482e05ff26281a58c76fc2</parent> 252 <ref>044e45ca-07b0-4496-bb32-61107f7c1796</ref> 253 <serial>2</serial> 254 <date>2026-02-14</date> 255 <dateTimeRegistered>2026-02-14T09:10:14Z</dateTimeRegistered> 256 <description>Barbarbar</description> 257 <debit type="expense"> 258 <unit>BTC</unit> 259 <account>luxury</account> 260 <amount>-421300</amount> 261 </debit> 262 <credit type="liability"> 263 <unit>BTC</unit> 264 <account>creditcard</account> 265 <amount>421300</amount> 266 </credit> 267 </data> 268 <sig type="ed25519" keyid="3b54648d60bb8a5b9e84fa0057f79b3a5996e511682e80176dc948dcbff5a4fc">425ae11c2d1808873c2da336a9c26386b6e45dd327f599186cca2766248bde62b38473e8a271119a6c382fa620f4c5a6de3471c2032824f76299360ef9e00009</sig> 269 </entry> 270 </ledger> 271 @end example