R/SDMXType-methods.R

Defines functions type.SDMXType SDMXType

Documented in SDMXType

#' @name SDMXType
#' @rdname SDMXType
#' @aliases SDMXType,SDMXType-method
#' 
#' @usage
#' SDMXType(xmlObj)
#' 
#' @param xmlObj object of class "XMLInternalDocument derived from XML package
#' @return an object of class "SDMXType"
#' 
#' @note
#' At now, the following types have been implemented and successfully tested:
#'  - \code{StructureType},
#'  - \code{GenericDataType},
#'  - \code{CompactDataType},
#'  - \code{StructureSpecificDataType},
#'  - \code{CrossSectionalDataType},
#'  - \code{UtilityDataType},
#'  - \code{MessageGroupType}
#' 
#' @seealso \link{readSDMX}
#'
SDMXType <- function(xmlObj){
	new("SDMXType", type = type.SDMXType(xmlObj));
}

type.SDMXType <- function(xmlObj){
  
  child <- xmlRoot(xmlObj)
  if(xmlName(child) == "RegistryInterface"){
    child <- xmlChildren(child)[[2]]
    if(xmlName(child) == "QueryStructureResponse") return("StructureType")
  }
  
  type <- xmlName(xmlRoot(xmlObj))
  if(attr(regexpr(":", type, ignore.case = T),"match.length") > 0){
    type <-strsplit(xmlName(xmlRoot(xmlObj), full=T), ":")[[1]][2]
  }  
	res <- paste(type, "Type", sep="");
	return(res)
}

Try the rsdmx package in your browser

Any scripts or data that you put into this service are public.

rsdmx documentation built on Aug. 28, 2023, 5:09 p.m.