-
Notifications
You must be signed in to change notification settings - Fork 16
Find elements in a taxonomy
Elements in a taxonomy are accessed by calling the method $taxonomy->getElements() where $taxonomy is a variable that references an instance of the XBRL class or a descendant.
$elements = &$taxonomy->getElements();
The returned value is an array of elements defined in the schema document of the taxonomy. From here the the array can be queried to retrieve any type of element using standard PHP functions.
The index values used in the array is the id value of the element so this is the way to go if you know the id.
The elements of the array are the attributes you would expect to find in an tag in the schema:
Attribute | Example |
---|---|
id | uk-gaap_CostSales |
name | CostSales |
type | xbrli:monetaryItemType |
substitutionGroup | xbrli:item |
periodType | duration |
balance | debit |
nillable | true |
An example of querying for all elements with a period type of 'duration' might be:
$duration = array_filter( $elements, function( $element ) {
return isset( $element['periodType'] ) && $element['periodType'] == 'duration';
} );
###Using the correct namespace
The $taxonomy variable value will have been set by a call to XBRL::loadTaxonomy or querying the the taxonomy of a loaded instance. However, the $taxonomy returned will be the main taxonomy of the DTS so may not be the one you want and not the one with schema file which defines the element.
It will usually be useful to make sure you are working with the correct taxonomy by explicitly retrieve the taxonomy for a namespace. This can be done using the getTaxonomyForNamespace the XBRL class:
$element_taxonomy = $taxonomy->getTaxonomyForNamespace( 'a valid namespace' );
Copyright © 2021 and later years Lyquidity Solutions Limited
- About us
- Purpose
- XBRL support
- Road Map
- Why PHP?
- Contributing
- License
- Reference links
- Case Study
- Digital Financial Reporting
- Digital Financial Reporting examples
Overview
Class and function reference
Compiled taxonomy structure
Common arrays
Compiling
Compiling
Processing linkbases
Additional taxonomy processing
Extension taxonomies
Compiled taxonomy folder
How do I...?
Navigate a node tree
Find a node in a tree
Find elements in a taxonomy
Load an instance document
Find elements in an instance
Create a simple report
Create a comparison report
Example custom report
Work with dimensions
Sign and Verify
Validate
Change the logging
Capture validation information