extract_dsd {restatapi} | R Documentation |
Extract the Data Structure Definition content from SDMX XML
Description
Extracts values from the XML Data Structure Definition (DSD) file
Usage
extract_dsd(concept = NULL, dsd_xml = NULL, lang = "en")
Arguments
concept |
a character vector with a concept id |
dsd_xml |
an XML file with DSD content |
lang |
a character string either |
Details
It is a sub-function to use in the get_eurostat_dsd
function.
Value
a matrix with 3 columns if the provided concept
has a code list in the DSD file. The first column is the provided concept
. The second column
is the possible codes under the given concept
. The last column is the name/description for the code in the second column, which can be used as labels.
Examples
id<-"med_rd6"
cfg<-get("cfg",envir=restatapi::.restatapi_env)
rav<-get("rav",envir=restatapi::.restatapi_env)
dsd_url <- paste0(eval(
parse(text=paste0("cfg$QUERY_BASE_URL$'",rav,"'$ESTAT$metadata$'2.1'$datastructure"))
),"/",eval(
parse(text=paste0("cfg$QUERY_PRIOR_ID$'",rav,"'$ESTAT$metadata"))
),id,"?",eval(
parse(text=paste0("cfg$QUERY_PARAMETERS$'",rav,"'$metadata[2]"))
),"=",eval(
parse(text=paste0("cfg$DATAFLOW_REFERENCES$'",rav,"'$datastructure[1]"))
)
)
if (!(grepl("amzn|-aws|-azure ",Sys.info()['release']))) options(timeout=2)
tryCatch({
dsd_xml<-xml2::read_xml(dsd_url)},
error=function(e){
message("Unable to download the xml file.\n",e)},
warning=function(w){
message("Unable to download the xml file.\n",w)})
if (exists("dsd_xml")) extract_dsd("FREQ",dsd_xml)
options(timeout=60)
[Package restatapi version 0.23.1 Index]