Creates a standard DDI element.
makeElement(
name,
children = NULL,
attributes = NULL,
content = NULL,
fill = FALSE,
...
)
A standard list element of class "DDI"
with reserved component names.
Character, a DDI Codebook element name.
A list of standard DDI codebook elements.
A vector of named values.
Character scalar.
Logical, fill the element with arbitrary values for its mandatory children and attributes
Other arguments, see Details.
Adrian Dusa
The structure of a DDI element in R follows the usual structure of
an XML node, as returned by the function as_list()
from package xml2,
with one additional (first) component named ".extra" to accommodate any other
information that is not part of the DDI element.
In the DDI Codebook, most elements and their attributes are optional, but some are mandatory. In case of attributes, some become mandatory only if the element itself is present. The mandatory elements need to be present in the final version of the Codebook, to pass the validation against the XML schema.
By activating the argument fill
, this function creates DDI elements
containing all mandatory (sub)elements and (their) attributes, filled with
arbitrary values that can be changed later on. Some recommended elements are
also filled, as expected by the CESSDA Data Catalogue profile for DDI
Codebook.
By default, the Codebook is assumed to have a single language for all
elements. The argument monolang
can be deactivated through the "...
"
gate, in which situation the appropriate elements will receive a default
argument xmlang = "en"
. For other languages, that argument can also be
provided through the "...
" gate.
One such DDI Codebook element is the stdyDscr
(Study Description), with the
associated mandatory children, for instance title, ID number, distributor,
citation, abstract etc.
The complete list of elements for which default values are added is: "IDNo", "titl", "titlStmt", "distrbtr", "distStmt", "holdings", "citation", "abstract", "stdyInfo", "stdyDscr", "prodDate", "software", "prodStmt", "docDscr" and "otherMat".
addChildren
getChildren
showDetails
stdyDscr <- makeElement("stdyDscr", fill = TRUE)
# easier to extract with:
getChildren("citation/titlStmt/titl", from = stdyDscr)
Run the code above in your browser using DataLab