Skip to content

Commit

Permalink
Merge pull request #215 from PacificCommunity/master
Browse files Browse the repository at this point in the history
SDMXCode to read parent codes properly
  • Loading branch information
eblondel authored Jan 8, 2025
2 parents b724c69 + 9c90ba9 commit e1dcec6
Show file tree
Hide file tree
Showing 3 changed files with 3,098 additions and 6 deletions.
12 changes: 10 additions & 2 deletions R/SDMXCode-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,16 @@ SDMXCode <- function(xmlObj, namespaces){
urn = xmlGetAttr(xmlObj, "urn")
if(is.null(urn)) urn <- as.character(NA)

parentCode = xmlGetAttr(xmlObj, "parentCode")
if(is.null(parentCode)) parentCode <- as.character(NA)
parentCode <- as.character(NA)
parentId <- xmlGetAttr(xmlObj, "parentCode")
if(!is.null(parentId)) parentCode <- parentId
parentNode <- getNodeSet(xmlDoc(xmlObj), "//ns:Parent//Ref", namespaces = strNs)
if(length(parentNode) == 1) parentCode <- xmlGetAttr(parentNode[[1]], "id")
if(length(parentNode) > 1) {
parentCode <- sapply(parentNode, function(x) { xmlGetAttr(x, "id") })
# we collapse the vector of parent codes into a single string as required by the SDMXCode class
parentCode <- paste(parentCode, collapse = ",")
}

#elements
#========
Expand Down
Loading

0 comments on commit e1dcec6

Please sign in to comment.