DDI-Lifecycle 4.0 (experimental)¶
Experimental
DDI-Lifecycle 4.0 is in public review. It is not a final standard. ddigraph
reads a 4.0 file only when you name the lifecycle4 flavor: it never
detects one. This flavor may change in any release, as the standard does.
What it reads¶
A DDI-Lifecycle 4.0 file is an ItemContainer in the namespace
ddi:instance:4_0. It may list some TopLevelReference elements first.
Then come its items:
<ItemContainer xmlns="ddi:instance:4_0">
<TopLevelReference>
<URN>urn:ddi:example.org:inst-1:1</URN>
<Agency>example.org</Agency><ID>inst-1</ID><Version>1</Version>
<TypeOfObject>Instrument</TypeOfObject>
</TopLevelReference>
<Instrument>
<URN>urn:ddi:example.org:inst-1:1</URN>
<Agency>example.org</Agency><ID>inst-1</ID><Version>1</Version>
<InstrumentName xml:lang="en">Health survey</InstrumentName>
<ControlConstructReference>
<URN>urn:ddi:example.org:seq-1:1</URN>
<Agency>example.org</Agency><ID>seq-1</ID><Version>1</Version>
<TypeOfObject>Sequence</TypeOfObject>
</ControlConstructReference>
</Instrument>
</ItemContainer>
The graph has the shape of a DDI-L 3 graph:
- Items. Each item is a node. Its label is its element name, such as
Instrument,CodeListorCategory. Its identity is the URN of itsAgency,IDandVersion. - Nested nodes. An element inside an item is a node too when it has
its own identity and DDI-L 3 has a label for it. A
Codein itsCodeListis one. Its parentCONTAINSit, in document order. - References. Each reference is a relationship, with the name DDI-L 3
gives it. A
ControlConstructReferenceisHAS_CONSTRUCT, and aConceptReferenceisUSES_CONCEPT. A reference that is new in 4.0 takes its element name withoutReference, in upper case. So aBroaderReferenceisBROADER. - Entry points. A
TopLevelReferenceis aHAS_ENTRY_POINTrelationship from the Dataset node, as in DDI-L 3. So is eachInstrumentandStudyUnitin the file. - Resolution. References resolve as in DDI-L 3, by
--resolve, and never across agencies. A reference to an item the file does not hold ends at a stub. Its label is the reference'sTypeOfObject. - Text. Names and labels keep their language, from
xml:lang.
Load and validate a file¶
Name the flavor on each command:
ddigraph validate items.xml --flavor lifecycle4
ddigraph load items.xml --format lifecycle4
ddigraph store add items.xml --flavor lifecycle4
validate checks the file against the bundled 4.0 schema,
schemas/ddi-l4/lifecycle40.xsd. Without the flavor, each command stops,
since it cannot tell which flavor the file is.
The schema's decimal type has a lowest and a highest value of 29 digits.
lxml on Windows cannot read numbers that long, so ddigraph drops those two
limits, in memory only and on every system. A decimal still has at most 29
digits.
In Python, give the flavor to ddigraph.ir.parse and write the stream
with a lens:
from ddigraph import ir
from ddigraph.lens.memory import MemoryLens
lens = MemoryLens()
lens.write(ir.parse("items.xml", flavor="lifecycle4", dataset_id="items"), dataset_id="items")
What it does not do yet¶
- Some properties. It reads each node's label, a category's label and
a sequence's count of constructs. A grid's response type is
codewhen one of the grid's dimensions has a code list, and is not set otherwise. 4.0 moves other DDI-L 3 properties into new elements. These are not read yet: a question's text and response type, a measurement's text, a study's title, a code list's count of codes, a category scheme's count of categories, a construct's condition and a variable's kind of representation. - Some names. It reads a node's name from the element DDI-L 3 reads it
from. Some 4.0 nodes keep their name in another element, such as
ArchiveModuleNameorDevelopmentActivityName. These names are not read yet: those ofArchive,ConceptualComponent,DataCollection,DDIProfile,GenericMap,LogicalProduct,MethodologyandPhysicalDataProduct, of the six development activities, and of the access and parameter nodes. - Copies of objects. 4.0 writes some references as a copy of the
object they name, not as a reference. A
CodeReferencein aCategoryValueis one: it is a wholeCode. So is an element whose name ends in_IdentifiableType, and theLocationValueaLocationValuesupersedes or precedes. A copy has noTypeOfObject. ddigraph does not read it: it makes no node and no relationship of the copy or of what it holds. - One node in two versions. A node that a DDI-L 3 dataset and a 4.0
dataset both hold keeps a label for each. Most labels are the same in
both versions, but 4.0 renames some objects. When each of the node's two
names is a label only its own version has, such as a 3.3
CategoryMapthat 4.0 callsGenericMap, the node keeps both labels and reads back in each dataset. When both files hold the object, one name is a label both versions have and the other is not, the second write stops with an error, and the first dataset still reads as it was. A 3.3RecordLayoutthat 4.0 callsProprietaryRecordLayoutis such a node, since 4.0 has aRecordLayouttoo. Load those two versions in two databases. A 4.0 file that only refers to such a node is not refused: it reads the node as theRecordLayoutthe 3.3 dataset holds. - Detection.
ddigraph detectnever returnslifecycle4.