Closed longhotsummer closed 4 years ago
A very hacky initial version of this is in the akn3-doc-types branch: https://github.com/laws-africa/cobalt/tree/akn3-doc-types
@longhotsummer will 'subtypes' still be used by indigo, e.g. /act/ordinance
, or will this become /ordinance
?
Subtypes are still very much a thing: https://docs.oasis-open.org/legaldocml/akn-nc/v1.0/os/akn-nc-v1.0-os.html#_Toc531692270
Any specification of document subtype, if appropriate. For an Akoma Ntoso XML representation, this value MUST correspond to the content of the element
in the metadata or, in its absence, to the “name” attribute of the document type (optional).
Just realised we don't use FRBRsubtype. Will make an issue for AKN3.
There are some old APIs which we can take this opportunity to improve/adjust.
_maker
attribute is useful externally, it shouldn't be private
with _
. So _maker
becomes maker
.to_xml
should take *args
and **kwargs**
and pass them on to etree's tostring
method.year
, number
etc. that simply proxy to the FRBR URI should be removed. Callers can use .frbr_uri.year
etc. instead._ensure
is useful externally, remove the _
and make it ensure_element
_make
is useful externally, remove the _
and make it make_element
_get
is useful externally, remove the _
and make it get_element
Items 1, 4, 5 and 6 can be on the root AkomaNtosoDocument
class since they're unrelated to the content of the document.
To be namespace safe, we should always use xml namespaces when working with nodes. So lines like self.root.iterfind('./{*}components/{*}component/{*}doc'):
should use the actual namespace, not *
.
The helper methods such as
year
,number
etc. that simply proxy to the FRBR URI should be removed. Callers can use.frbr_uri.year
etc. instead.
year
does a little more: it gives the year from frbr_uri.date.
Shall we just nuke number
(and nature
, and have people use .frbr_uri.doctype
)?
The helper methods such as
year
,number
etc. that simply proxy to the FRBR URI should be removed. Callers can use.frbr_uri.year
etc. instead.
year
does a little more: it gives the year from frbr_uri.date. Shall we just nukenumber
(andnature
, and have people use.frbr_uri.doctype
)?
Since year
comes from the FRBR URI, I still think it should be moved there. Anything that's a simply proxy to the frbr_uri should be removed. Otherwise it clutters the API.
closed by #23
The goal is to ensure Cobalt can provide at least basic support for arbitrary Akoma Ntoso document types (section 5 of the spec).
The AKN model includes a number of document types with specific root elements and document models. Cobalt's object hierarchy should mimic these document types, making it simpler to map between AKN and Cobalt.
A summary of the document types, primary elements, primary body elements etc. is in https://docs.google.com/spreadsheets/d/1Y9DJu0-IaINyhCjRQRtIQLmsadtLVFlqidI4gy_OAWA/edit#gid=2028639471
Proposal
Cobalt should provide factory code that takes an XML tree (or text) and determines what type it is, then instantiates the appropriate class.
Example
This could look something like this: