low-level: Set of low-level functions to parse an XBRL file and extract...

Low-level functionsR Documentation

Set of low-level functions to parse an XBRL file and extract information from it.

Description

xbrlParse performs the parsing of the document. It returns a pointer to external memory used by the low-level functions. xbrlFree releases the external memory used.

xbrlGetSchemaName is used on an instance document to extract the name of the associated schema. xbrlGetLinkbaseNames and xbrlGetImportNames are used on a taxonomy document to extract the names of linked documents during the process of discovery.

xbrlProcessXXX functions are used to extract information from taxonomy and instance files in the form of data frames.

Usage

## Use on any XBRL file
xbrlParse(file)
xbrlFree(doc)

## Use on an instance file
xbrlGetSchemaName(doc)

## Use on a taxonomy file
xbrlGetLinkbaseNames(doc)
xbrlGetImportNames(doc)

xbrlProcessElements(doc)
xbrlProcessLabels(doc)
xbrlProcessArcs(doc, arcType)

## Use on a schema file
xbrlProcessRoles(doc)

## Use on an instance file
xbrlProcessContexts(doc)
xbrlProcessFacts(doc)
xbrlProcessUnits(doc)
xbrlProcessFootnotes(doc)

Arguments

file

the name of the XBRL document. It can be a URL or local file name

doc

pointer to external memory, returned by xbrlParse

arcType

Either "presentation", "calculation", or "definition"

Value

xbrlParse returns an external pointer.

xbrlFree returns NULL.

xbrlGetSchemaName, xbrlGetLinkbaseNames and xbrlGetImportNames return a character vector

xbrlProcessXXX returns a data.frame

Author(s)

Roberto Bertolusso and Marek Kimmel

See Also

xbrlDoAll

Examples

## Not run: 
## Setting stringsAsFactors = FALSE is highly recommended
## to avoid data frames to create factors from character vectors.
options(stringsAsFactors = FALSE)

## XBRL instance file to be analyzed.
## NOTE: in this case, inst needs to be a local file, or accessible
##       as http (not https).
inst <- "ko-20130927.xml"
## Parse the instance (doc is an pointer to
## external memory that needs to be freed after use):
doc <- xbrlParse(inst)
## Get a data frame with facts:
fct <- xbrlProcessFacts(doc)
## Get a data frame with contexts:
cts <- xbrlProcessContexts(doc)
## Get a data frame with units:
unt <- xbrlProcessUnits(doc)
sch <- xbrlGetSchemaName(doc)
## Free the external memory used:
xbrlFree(doc)

dname <- dirname(inst)
## Parse the schema file:
docS <- xbrlParse(paste0(dname,"/",sch))
## Get roles:
rls <- xbrlProcessRoles(docS)
head(rls)
## Free the external memory used:
xbrlFree(docS)

## End(Not run)

XBRL documentation built on March 29, 2022, 1:05 a.m.