xml.texi (3569B)
1 @chapter Data representation 2 3 The canonical ledger data format is XML. 4 5 The XML schema is designed to allow embedding of all data necessary to verify integrity signatures, including exchange rates between units of account. It also contains additional elements that are not part of the signature, but enriches the context of the ledger and its composite parts. 6 7 Order of elements are important in the XML document. The schema is cited in @ref{xml_schema, appendix A}. 8 9 10 @anchor{ledger_header} 11 @section Ledger header 12 13 The responsibility of the ledger header is to give the consumer the necessary resources to validate the entries in the ledger. 14 15 It includes: 16 17 @itemize 18 @item The document version, indicating which version of schema to use. 19 @item Topic, which uniquely identifies the legder instance. 20 @item Generation date and time of the XML document. 21 @item Index of units of account used in the following entries. @xref{unit_index,Unit Index} 22 @item The public key identities whose signatures appear in the document. @xref{identity,Public Key Identities} and their trust details. 23 @item Details on resolver services that can be used to expand assets references by digests. @xref{resolver, Resolvers} and @ref{assets, Referencing assets}. 24 @item Ledger state, under the element @code{incoming}, defining the digest of the position of the entry chain the ledger document starts at. @xref{incoming, Ledger State}. 25 @item Signatures that may authenticate the ledger state. 26 @end itemize 27 28 29 @anchor{ledger_trunc_header} 30 @subsection Truncated header 31 32 An important feature of the header is to allow only a portion of the ledger's entries to appear in the document. 33 34 This is accomplished by populating the @code{digest} and @code{serial} values in the ledger state with those of the parent of the first entry listed. @xref{xml_example, The XML example} for more details. 35 36 In order to list all entries in a ledger, the @code{digest} value should be the zero-digest (64 zero-value bytes), and with a @code{serial} of @code{0}. 37 38 39 @section Entry 40 41 Every entry is comprised of two or more parts, where there is at least one debit and one credit part. All the parts should add up to 0. 42 43 The parts represents instantaneous changes in the ledger within a single entry. E.g. at the same time an expense account and a sales tax credit. 44 45 Each part may have different units of account. In this case, conversion rates for each part must be provided in order to verify the zero sum of the parts. 46 47 The debit and credit entry part elements have identical stucture, and include: 48 49 @itemize 50 @item The unit of account. 51 @item The account specifier, which is a combination of @ref{account_type, account type}, and @ref{account_path, account path}. 52 @item The amount in the unit of account, as decimal integer to the level of precision defined for the unit. 53 @end itemize 54 55 The entry representation also defines data necessary for the immutability chain to be verified: 56 57 @itemize 58 @item The digest of the parent. 59 @item The serial number of this entry in the ledger. 60 @item The external reference of the entry, e.g. a blockchain transaction specificer or tax invoice uuid. 61 @item The date or datetime when the transaction took place. @xref{entry_timing, Entry timing}. 62 @item The datetime when the transaction was registered in the ledger. 63 @item A free-text description for the entry. 64 @end itemize 65 66 67 @anchor{data_unit_index} 68 @section Unit Index 69 70 The unit index exchange rate is represented as an integer with 9 decimal precision. 71 72 For example, a value of @code{1.0} is represented as the integer @code{1000000000}.