XBRL Query and Rules Language 1.0

Public Working Draft 11 June 2024

This version
https://www.xbrl.org/Specification/xbrl-rules-3.0/PWD-2024-06-11/xbrl-rules-3.0-PWD-2024-06-11.html
Editors
Phillip Engel <phillip@goffengel.com>
Campbell Pryde <campbell.pryde@xbrl.us>
Contributors
David M. Shaw <dmshaw@fasb.org>
Herm Fischer <herm@exbee.dev>
Paul Warren <pdw@xbrl.org>

Table of Contents

Definitions

Error codes

1 Introduction

The XBRL Query and Rules Language is a specialized query language designed for querying XBRL (eXtensible Business Reporting Language) data and uses a data model based on the XBRL Open Information Model (OIM). Its primary purpose is to effectively query XBRL data by extracting data points, performing calculations and applying rules or validations. The notable feature of XBRL Query and Rules Language is that it is syntax-independent and can support processing queries of XBRL data in any supported format (e.g., xBRL-XML, xBRL-CSV, xBRL-JSON).

1.1 Relationship to other work

XBRL Query and Rules Language is a successor to XBRL Formula 1.0.

XBRL Query and Rules Language builds upon the capabilities of XBRL Formula 1.0 and expands its capabilities to also provide broader querying capabilities. This enhancement supports the growing complexity and diversity of use cases for XBRL data. XBRL Query and Rules Language provides more flexibility and functionality beyond the scope of providing calculations and validation.

1.2 Terminology

The key words MUST, MUST NOT, REQUIRED, SHALL, SHALL NOT, SHOULD, SHOULD NOT, RECOMMENDED, MAY, and OPTIONAL, in this specification, are to be interpreted as described in IETF RFC 2119.

The keywords expanded name, NCName and QName are to be interpreted as described in the XML Names specification.

1.3 Documentation conventions

QNames in parenthetical red text after a "MUST" or "MUST NOT" statement prescribe standardized error codes to be used if the preceding condition is violated. "MUST" or "MUST NOT" statements that do not have a prescribed error code are not automatically enforceable, and processors are not required to detect violations.

1.4 Namespaces and prefixes

This specification makes use of QName notation to refer to XML expanded names (the combination of a namespace URI and a local name, and the xBRL-JSON format make use of abbreviated forms for these identifiers. The prefixes used by this specification are shown in the table below. These prefixes are reserved prefixes.

Prefix Namespace URI
xbrl https://xbrl.org/2021
dtr-type http://www.xbrl.org/dtr/type/*
xs http://www.w3.org/2001/XMLSchema
xbrldt http://xbrl.org/2005/xbrldt
xbrlqe http://xbrl.org/2024/xbrl-query/error

The prefix dtr-type denotes any namespace that is the namespace for a type defined in the Data Types Registry.

2 Querying XBRL Data (Informative)

The XBRL Query and Rules Language is a domain specific language used to define queries and assertions over an XBRL instance or taxonomy. The language is based on the XBRL data model. Queries are written in text files. A query is basically a formula that can access XBRL data and calculate a new value. The calculated value can either be outputted or used to generate an assertion message.

The result of the query is a message or set of messages as output. The message can be either the query result or can be an assertion. Assertions are used to test XBRL data and produce messages when the assertion is not met. For example, Equities is not equal to Assets + Liabilities is an assertion that when the sum of the values for Assets and Liabilities does not equal Equities a message is produced to indicate the data is out of balance.

This output query will calculate the value of Equities by adding Assets and Liabilities

output EquitiesValue
    @Assets + @Liabilities

This assert query will display message when Equities does not equal the sum of Assets and Liabilities

assert OutOfBalance
    @Equities#e != @Assets#a + @Liabilities#l
message
    'The value of Equities {$e} does not equal the sum {$a + $l} of Assets {$a} and Liabilities {$l}'

The language has two distinct components: fact filtering and taxonomy navigation.

2.1 Querying for XBRL Facts

Every fact defined in an XBRL instance document has dimensions associated with it, that define the fact. These dimensions include the built in dimensions:

In addition to the built in dimensions, facts can have additional taxonomy dimension, such as "Business Segment Dimension", "Geography Dimension", and "Energy Source Dimension". These dimensions allow disaggregated facts to be reported.

Instance document filtering allows queries to use these dimensions to select facts. XBRL Query and Rules Language provides 2 special features when filtering instance documents.

2.1.1 Creating Query Iterations

A unique feature of XBRL Query and Rules Language is that when multiple facts are selected to use in an expression, such as to list values for Revenues, XBRL Query and Rules Language will automatically repeat the execution of the query for each occurrence of the fact in the XBRL data.

This query will output the value for each Revenues fact.

output EquitiesValue
    @Revenue
message "Revenues: {$rule-value} for period: {$rule-value.period}"

This query uses a fact query to obtain the value of Revenues. If the XBRL instance document contains 3 years of revenues as follows:

Revenues value Period
10,000 2021-01-01 to 2021-12-31
20,000 2022-01-01 to 2022-12-31
30,000 2023-01-01 to 2023-12-31

The following results are produced:

Revenues: 10,000 for period: 2021-01-01 to 2021-12-31
Revenues: 20,000 for period: 2022-01-01 to 2022-12-31
Revenues: 30,000 for period: 2023-01-01 to 2023-12-13

2.1.2 Alignment of facts

When combining multiple facts in a query the XBRL Query and Rules Language will align the facts based on the dimensions of facts. For example, if calculating the value of Equities by adding Assets and Liabilities, only the Assets and liabilities for the same period would be calculated.

This query will calculate the value of Equities by adding Assets and Liabilities.

output EquitiesValue
    @Assets#a + @liabilities#l
message "{$rule-value} (Equities) = {$a} (Assets) + {$l} (Liabilities) for period: {alignment()['period']}"

This query uses 2 fact queries to get the values for Assets and Liabilities. If the XBRL instance document contains 3 years of Assets and liabilities as follows:

Period Assets liabilities
2021-12-31 100,000 110000
2022-12-31 200,000 210,000
2023-12-31 300,000 310,000

The following results are produced:

210,000 (Equities) = 100,000 (Assets) + 110,000 (Liabilities) for period: 2020-12-31
410,000 (Equities) = 200,000 (Assets) + 210,000 (Liabilities) for period: 2021-12-31
610,000 (Equities) = 300,000 (Assets) + 310,000 (Liabilities) for period: 2023-12-31

Note that the Assets and liabilities are automatically aligned based on period. By default, the XBRL Query and Rules Language will not create an iteration where the Assets and liabilities have different periods. How the processor aligns facts in an iteration is controllable by the query.

2.2 Taxonomy navigation

In addition to query for XBRL facts, the XBRL Query and Rules Language provides extensive support for navigating taxonomies. For example, the XBRL Query and Rules Language can compare the structure of a company extension taxonomy against the underlying authoritative taxonomy (i.e. US GAAP Taxonomy or IFRS Taxonomy).The resulting taxonomy relationship sets can then be combined with a fact query to determine where values have been used. These navigation features are explained in detail in the Navigation section of this document. (see Section 7)

2.3 Data Model

The query language follows the XBRL data model, defining objects and properties that can be used to understand an XBRL filing or Taxonomy. The model operates at a semantic level - no operations are dependent on any underlying xml, json or csv syntax, although the model does allow access to some syntactic components using functions. This document defines all of the object classes and properties of those classes. An understanding of the XBRL data model is essential to use the query language.

3 Query Data Model

The Query Data Model is composed of the Taxonomy Object Model and the Instance Object Model.

An object represents the components of XBRL taxonomies and XBRL instances. An object represents a unique XBRL artifact such as a concept or a label. All objects are comprised of properties that define the attributes of the object.

An object property defines the attributes of an object.

The query language operates on objects defined in the Query Data Model.

The Query Data Model does not support tuples.

The Taxonomy Object Model defines the objects in a valid XBRL taxonomy. The Taxonomy Object model includes properties of each object.

The taxonomy object model shown in Figure 1 is comprised of the following objects:

Figure 1: Taxonomy Object Model

The Instance Object Model defines the objects in an XBRL Instance. The Instance Object model includes properties of each object.

The instance object model shown in Figure 2 is comprised of the following objects:

Figure 2: Instance Object Model

Properties of each object are accessed using a dot notation.

The example below shows the cube object with a property of cube-concept which is a concept object which has a property of data-type.

$cube.cube-concept.data-type

3.1 Taxonomy Objects

The taxonomy object model is comprised of the following components.

3.1.1 Taxonomy Object

The taxonomy object defines the properties of a taxonomy.

The expression below defines the US-GAAP taxonomy object.

constant $US-GAAP-2020 = taxonomy('https://xbrl.fasb.org/us-gaap/2020/entire/us-gaap-entryPoint-all-2020-01-31.xsd')

3.1.1.1 Taxonomy Object Properties

The taxonomy concepts property returns a set of all concept objects comprising the taxonomy object.

The expression below returns a set of all the concepts from the US-GAAP taxonomy object.

$US-GAAP-2020.concepts

The taxonomy concept-names property returns a set of all concept QNames comprising the taxonomy object.

The expression below returns a set of all the concept QNames from the US-GAAP taxonomy object.

$US-GAAP-2020.concept-names

The taxonomy cubes property returns a set of all cube objects comprising the taxonomy object.

The expression below returns a set of all cube objects from the US-GAAP taxonomy object.

$US-GAAP-2020.cubes

The taxonomy dimensions property returns a set of all dimension objects comprising the taxonomy object.

The expression below returns a set of all dimension objects from the US-GAAP taxonomy object.

$US-GAAP-2020.dimensions

The taxonomy dimensions-explicit property returns a set of all explicit dimension objects comprising the taxonomy object.

The expression below returns a set of all explicit dimension objects from the US-GAAP taxonomy object.

$US-GAAP-2020.dimensions-explicit

The taxonomy dimensions-typed property returns a set of all typed dimension objects comprising the taxonomy object.

The expression below returns a set of all typed dimension objects from the US-GAAP taxonomy object.

$US-GAAP-2020.dimensions-typed

The taxonomy dts-document-locations property returns a set of url or file paths comprising all the files that make up the discoverable taxonomy set (dts).

The expression below returns a set of all dts document locations from the US-GAAP taxonomy object.

$US-GAAP-2020.dts-document-locations

The taxonomy entry-point property returns the url of the entry point file of the taxonomy object.

The expression below returns the entry point of US-GAAP taxonomy object as a url.

$US-GAAP-2020.entry-point

The taxonomy entry-point-namespace returns the uri of the namespace for the entry point file of the taxonomy object.

The expression below returns the entry point namespace of US-GAAP taxonomy object as a url.

$US-GAAP-2020.entry-point-namespace

The taxonomy networks property returns a set of all network objects comprising the taxonomy object.

The expression below returns a set of all network objects from the US-GAAP taxonomy object.

$US-GAAP-2020.networks

The taxonomy namespaces property returns a set of all namespace uri's comprising the taxonomy object. This includes every namespace comprising the dts.

The expression below returns a set of all namespace uri's from the US-GAAP taxonomy object.

$US-GAAP-2020.namespaces

The query will return a set of 255 unique namespaces.

The taxonomy roles property returns a set of all role objects comprising the taxonomy object. This does not include arcroles.

The expression below returns a set of all roles used in the US-GAAP taxonomy object.

$US-GAAP-2020.roles

The taxonomy arcroles property returns a set of all arcrole objects comprising the taxonomy object.

The expression below returns a set of all arcroles used in the US-GAAP taxonomy object.

$US-GAAP-2020.arcroles

The taxonomy part-elements property returns a set of all part-element QNames comprising the taxonomy object.

The expression below returns a set of all part-elements used in the US-GAAP taxonomy object.

$US-GAAP-2020.part-elements

The taxonomy elements property returns a set of element QNames that are not part-elements or concepts comprising the taxonomy object.

The expression below returns a set of all element QNames used in the US-GAAP taxonomy object.

$US-GAAP-2020.elements

The taxonomy data-types property returns a set of all type objects comprising the taxonomy object.

The expression below returns a set of all the data types used by the US-GAAP taxonomy object.

$US-GAAP-2020.data-types

The taxonomy uri property returns the url of the entry point file of the taxonomy object.

The expression below returns the entry point of US-GAAP taxonomy object as a url.

$US-GAAP-2020.uri

This returns https://xbrl.fasb.org/us-gaap/2020/entire/us-gaap-entryPoint-all-2020-01-31.xsd

3.1.1.2 Taxonomy Object Properties/Functions with Parameters

The taxonomy object has the following functions.

3.1.2 Concept Object

The concept object defines an XBRL concept. The concept object includes the concepts properties and traits. The query specification treats labels and references as properties of the concept object.

The expression below defines the Assets concept in the $US-GAAP-2020 taxonomy, using concept(concept qname ) (see Section 11.2.1).

constant $Assets = $US-GAAP-2020.concept(Assets)

3.1.2.1 Concept Object Properties

The concept balance property returns a string value of either debit, credit or empty string. This property corresponds to balance defined in the XBRL specification.

The query expression below returns the balance of the Assets concept object as a string.

$Assets.balance

The concept base-type property returns a base-type of the data-type of the concept. The base-type is represented as a type object.

The query expression below returns the base-type of the Assets concept object as a type object.

$Assets.base-type

The concept data-type property returns a data-type of the concept. The data-type is represented as a type object.

The query expression below returns the data-type of the Assets concept object as a type object of monetaryItemType.

$Assets.data-type

The concept enumerations property returns a set of strings derived from the data-type object of the concept. This is a short form of $concept.data-type.enumerations

The query expression below returns a set of strings representing the possible enumerated values if there are any. In this case there are none so an empty set is returned.

$Assets.enumerations

The concept ext-enum property returns a set of enumerated values allowed for the concept based on an ext-enum object.

The query expression below returns a set of enumerated values representing the possible enumerated values if there are any. In this case there are none so an empty set is returned.

$Assets.ext-enum 

The concept has-enumerations property returns a boolean derived from the data-type object of the concept. This is a short form of $concept.data-type.has-enumerations

The query expression below returns a boolean value if the concept has enumerated values. In this case there are none so a boolean value of false is returned.

$Assets.has-enumerations

The concept is-abstract property returns a boolean indicating the concept is an abstract, a value of true or the concept is not an abstract, a value of false.

The query expression below returns a boolean value of false for the Assets concept.

$Assets.is-abstract 

The concept is-monetary property returns a boolean indicating if the QName of the data type object of the concept equals xbrli:monetaryItemType.

The query expression below returns a boolean value of true for the Assets concept, as it is a monetaryItemType.

$Assets.is-monetary

The concept is-numeric property returns a boolean value of true indicating if the QName of the base-type is derived from decimal, double or float.

The query expression below returns a boolean value of true for the Assets concept, as it is a numeric type.

$Assets.is-numeric

The concept local-name property returns a string representing the suffix of the QName.

The query expression below returns the local-name of Assets which is Assets.

$Assets.local-name

The concept name property returns a QName of the concept.

The query expression below returns the QName of Assets which is us-gaap:Assets.

$Assets.name

The concept namespace-uri property returns a uri representing the namespace of the QName of the concept.

The query expression below returns the namespace-uri of Assets which is http://fasb.org/us-gaap/2020-01-31

$Assets.namespace-uri

The concept nillable property returns a boolean indicating the concept is nillable.

The query expression below returns a boolean value of true for the Assets concept, as it is nillable.

$Assets.nillable

The concept period-type property returns a string value of either instant or duration string. The period-type attribute when defined in a expression it is defined as a keyword.

The query expression below returns string value of instant for Assets.

$Assets.period-type

The concept all-references property returns a set of all reference objects associated with the concept.

The query expression below returns a set of all references for Assets.

$Assets.all-references

The concept substitution property returns a type object of the substitution group of the concept.

The query expression below returns the data-type object of the substitution group.

$Assets.substitution

The concept traits property returns a set of trait concept objects associated with the concept.

The query expression below returns the set of traits associated with the Assets concept.

$Assets.traits

3.1.2.2 Concept Object Properties/Functions with Parameters

The concept object has the following associated properties that take parameters.

3.1.3 Cube Object

The cube object defines the properties of an XBRL hypercube based on the drs role.

The expression below defines the cube object in the $US-GAAP-2020 taxonomy for ScheduleOfFairValueOffBalanceSheetRisksTable using cube(statement table concept|QName, drs-role)(see Section 11.2.2).

constant $CUBE = $US-GAAP-2020.cube(ScheduleOfFairValueOffBalanceSheetRisksTable, FinancialInstrumentsFairValueDisclosuresScheduleOfFairValueOffBalanceSheetRisksTable)

The full uri of the drs-role is http://fasb.org/us-gaap/role/disclosure/ FinancialInstrumentsFairValueDisclosuresScheduleOfFairValueOffBalanceSheetRisksTable

3.1.3.1 Cube Object Properties

The cube cube-concept property returns a concept object or hypercube concept in the substitution group xbrldt:hypercubeItem

The expression below returns the table name of the cube object. In this case ScheduleOfFairValueOffBalanceSheetRisksTable.

$CUBE.cube-concept

The cube closed property returns a boolean value representing if the hypercube is closed, a value of true or the hypercube is open, a value of false.

The query expression below returns the boolean value of the closed attribute.

$CUBE.closed

The cube drs-role property returns a role object representing the drs role of the cube.

The query expression below returns the drs-role of the cube object.

$CUBE.drs-role

The cube dimensions property returns a set of dimension objects of the cube. Each dimension is a dimension object.

The query expression below returns a set of dimensions of the cube object. Each dimension is a dimension object.

$CUBE.dimensions

The cube dimensions-explicit property returns a set of explicit dimension objects of the cube. Each dimension is a dimension object.

The query expression below returns a set of dimensions of the cube object. Each dimension is a dimension object.

$CUBE.dimensions-explicit

The cube dimensions-typed property returns a set of typed dimension objects of the cube. Each dimension is a dimension object.

The query expression below returns a set of dimensions of the cube object. Each dimension is a dimension object.

$CUBE.dimensions-typed

The cube primary-concepts property returns a set of primary concepts of the cube. Each primary concept is represented as a concept object. Primary concepts do not include domain members.

The query expression below returns a set of primary concepts associated with the cube object.

$CUBE.primary-concepts

The cube facts property returns a list of fact objects that are valid in the cube. The cube includes nil and duplicate facts.

The query expression below returns a list of fact objects that are valid in the cube.

$CUBE.facts

3.1.3.2 Cube Object Properties/Functions with Parameters

The cube object has the following associated properties that take parameters.

3.1.4 Dimension Object

The dimension Object defines the properties of an XBRL dimension based on the drs role. The dimension object is different from the dimension concept. The dimension object is a dimension on a cube in a given link role with members, domains and defaults. The dimension concept is a concept object representing the properties of the concept. The dimension concept is the dimension concept property of the dimension object.

The query expression below defines the dimension object of the cube object for the dimension StatementGeographicalAxis using dimension(dimension QName) (see Section 11.6.1).

constant $DIMENSION = $CUBE.dimension(srt:StatementGeographicalAxis)

3.1.4.1 Dimension Object Properties

The dimension concept property returns the concept object for the dimension.

The query expression below returns the concept object associated with the dimension.

$DIMENSION.concept

The dimension dimension-type property returns a string of either typed or explicit

The query expression below returns string value of explicit for the dimension.

$DIMENSION.dimension-type

The dimension default property returns the concept object for the default concept of the dimension.

The query expression below returns the default concept associated with the dimension if there is one. A value of none is returned if there is no default.

$DIMENSION.default

The dimension members property returns a set of concept objects for the domain members of the dimension.

The query expression below returns a set of domain member concepts associated with the dimension. If there are no members then an empty set is returned.

$DIMENSION.members

The dimension cube property returns the cube object for the dimension object.

The query expression below returns a cube object for the specified dimension. A dimension object can only be associated with one cube.

$DIMENSION.cube

3.1.5 Relationship Object

The relationship object defines an XBRL relationship between two concepts. The relationship object does not include relationships between concepts and resources. The relationship object includes generic relationships.

The following constants define a network object called $NETWORK_BS. This the Balance sheet for the US-GAAP taxonomy.

The second constant $PRES_RELATIONSHIP_OBJECT selects the first relationship object that links NotesAndLoansReceivableNetNoncurrentAbstract and NotesAndLoansReceivableGrossNoncurrent.

constant $NETWORK_BS = networks($US-GAAP-2020,parent-child,'http://fasb.org/us-gaap/role/statement/StatementOfFinancialPositionClassified')

constant $PRES_RELATIONSHIP_OBJECT = first(filter sum($NETWORK_BS).relationships where $item.source-name == NotesAndLoansReceivableNetNoncurrentAbstract and $item.target-name == NotesAndLoansReceivableGrossNoncurrent)

3.1.5.1 Relationship Object Properties

The relationship source property returns a concept object that represents the source concept in a relationship object.

The following query expression will return the source concept NotesAndLoansReceivableNetNoncurrentAbstract.

$PRES_RELATIONSHIP_OBJECT.source

The relationship source-name property returns a QName that represents the source concept in a relationship object.

The following query expression will return the source name NotesAndLoansReceivableNetNoncurrentAbstract as a QName.

$PRES_RELATIONSHIP_OBJECT.source-name

The relationship target property returns a concept object that represents the target concept in a relationship object.

The following query expression will return the target concept NotesAndLoansReceivableGrossNoncurrent as a concept object.

$PRES_RELATIONSHIP_OBJECT.target

The relationship target-name property returns a QName that represents the target concept in a relationship object.

The following query expression will return the target concept NotesAndLoansReceivableGrossNoncurrent as a QName.

$PRES_RELATIONSHIP_OBJECT.target-name

The relationship order property returns a decimal that represents the order attribute of the relationship object.

The following query expression will return the order attribute of the relationship.

$PRES_RELATIONSHIP_OBJECT.order

The relationship weight property returns an integer that represents the weight attribute of the relationship object.

The following query expression will return the weight of the relationship. Beacuse this is a presentation the property will return none.

$PRES_RELATIONSHIP_OBJECT.weight

The relationship preferred-label property returns a uri that represents the preferred label of a relationship object.

The following query expression will return the preferred label of the relationship as a uri.

$PRES_RELATIONSHIP_OBJECT.preferred-label

The relationship role property returns a role object that represents the extended link role the relationship object is present in.

The query expression below will return the preferred label of the relationship as a uri.

$PRES_RELATIONSHIP_OBJECT.role

The relationship arcrole property returns a role object that represents the arcrole of the relationship object.

The query expression below will return the arcrole of the relationship as a role object. i.e. parent-child

$PRES_RELATIONSHIP_OBJECT.arcrole

The relationship arcrole-uri property returns a string that represents the uri of the arcrole of the relationship object.

The query expression below will return the arcrole of the relationship as a role uri. i.e. http://www.xbrl.org/2003/arcrole/parent-child

$PRES_RELATIONSHIP_OBJECT.arcrole-uri

The relationship arcrole-description property returns a string that represents the description of the arcrole of the relationship object.

The query expression below will return the arcrole description of the relationship as a string. i.e. 'Parent/Child relationship'

$PRES_RELATIONSHIP_OBJECT.arcrole-description

The relationship link-name property returns a QName that represents the linkbase the relationship object is defined in.

The standard link name of a network could include presentationLink, calculationLink, definitionLink and genericLink. In addition a custom link could be defined in a taxonomy. The query expression below will return the link-name of the relationship as a QName. i.e. 'presentationLink'

$PRES_RELATIONSHIP_OBJECT.link-name

The relationship arc-name property returns a QName that represents the arc-name the relationship object is defined in.

The arc-name of a network could include link:presentationArc, calculationArc, definitionArc. In addition a custom arc could be defined in a taxonomy. The query expression below will return the arc-name of the relationship as a QName. i.e. 'presentationArc'

$PRES_RELATIONSHIP_OBJECT.arc-name

The relationship network property returns a network object that represents the network the relationship object is present in.

The query expression below will return the network object the relationship object is in.

$PRES_RELATIONSHIP_OBJECT.network

3.1.6 Label Object

The label object defines the properties of an XBRL label. If the label object is used as a property of a concept then the label object will default to the standard label. To get all labels the all-labels function of the concept is used. (see Section 11.3.1

3.1.6.1 Label Object Properties

The label lang property returns the language of a label as a string

The following will return the language used for the standard role of http://www.xbrl.org/2003/role/label

$US-GAAP-2020.concept(Assets).label.lang

The label role property returns the role object of the label.

The following will return the standard role of http://www.xbrl.org/2003/role/label

$US-GAAP-2020.concept(Assets).label.role

The label text property returns the text of a label as a string

The following will return the label text used for the standard role of http://www.xbrl.org/2003/role/label

$US-GAAP-2020.concept(Assets).label.text

This will return a string such as 'Assets'.

3.1.7 Reference Object

The reference object defines the properties of an XBRL reference.

3.1.7.1 Reference Object Properties

The reference parts property returns a set of part objects.

The reference role property returns the role object of the reference.

3.1.8 Reference-part Object

The reference-part object defines the properties of an XBRL reference part.

3.1.8.1 Reference-part Object Properties

The reference-part part-value property returns a string representing the value of the part.

For example the part-value of the part name ref:publisher could be 'FASB' or 'IFRS'

The reference-part name property returns the QName of the part. The property follows the format $part.name where $part is the reference reference-part object.

The reference-part namespace-uri property returns a uri representing the namespace of the reference-part name property. The property follows the format $part.namespace-uri where $part is the reference reference-part object.

The reference-part local-name property returns a string representing the local name of the reference-part name property. The property follows the format $part.local-name where $part is the reference reference-part object.

The reference-part order property returns a decimal representing the order of the part in the reference > The property follows the format $part.order where $part is the reference reference-part object. The part order property is not defined in the XBRL specification. The part order property is calculated based on the order of the parts in the taxonomy schema document.

The reference-part element property returns the QName of the part element.

Reference example using the part-value and part name property.

 $con = $US-GAAP.concept(Assets);

for ($ref in $con.references('http://www.xbrl.org/2003/role/presentationRef'))
    list("reference\n",
        for ($p in $ref.parts)
         $p.name.string + " - " + $p.part-value + "\n"
    ).join("")

The example returns a string of all the references for the concept Assets in the us-gaap taxonomy and adds some formatting.

The first reference is returned as the following string:

reference
ref:Publisher - FASB
ref:Name - Accounting Standards Codification
codification-part:Topic - 942
codification-part:SubTopic - 210
ref:Section - S99
ref:Paragraph - 1
ref:Subparagraph - (SX 210.9-03(11))
codification-part:URI - http://asc.fasb.org/extlink&amp;oid=6876686&amp;loc=d3e534808-122878

3.1.9 Network Object

The network object represents a single network in the taxonomy, identified by its extended link role, arcrole, standard arc element, and standard extended link element .

The query expression below defines the network object of the Balance Sheet in the US-GAAP-2020 taxonomy object using networks(arcrole, extended link role) (see Section 11.2.6).

constant $NETWORK_BS = $US-GAAP-2020.networks(parent-child,'http://fasb.org/us-gaap/role/statement/StatementOfFinancialPositionClassified')

3.1.9.1 Network Object Properties

The network arcrole property returns a role object that represents the arcrole of the network object.

The following query expression will return the arcrole parent-child used in the network object.

$NETWORK_BS.arcrole

The network arcrole-description property returns a string that represents the description of the arcrole of the network object.

The query expression below will return the arcrole description of the relationship as a string. i.e. 'Parent/Child relationship'

$NETWORK_BS.arcrole-description

The network arcrole-uri property returns a string that represents the uri of the arcrole of the network object.

The query expression below will return the arcrole uri of the relationship as a string. i.e. 'http://www.xbrl.org/2003/arcrole/parent-child'

$NETWORK_BS.arcrole-uri

The network concept-names property returns a set of concept QNames that are included as source-name and target-name of the relationships in the network object.

The following query expression will return a set of QNames used in the network object.

$NETWORK_BS.concept-names

The network concepts property returns a set of concept objects that are included as source and target concepts of the relationships in the network object.

The following query expression will return a set of concept objects used in the network object.

$NETWORK_BS.concepts

The network source-concepts property returns a set of concept objects that are included as source concepts of the relationships in the network object.

The following query expression will return a set of source concept objects used in the network object.

$NETWORK_BS.source-concepts

The network target-concepts property returns a set of concept objects that are included as target concepts of the relationships in the network object.

The following query expression will return a set of target concept objects used in the network object.

$NETWORK_BS.target-concepts

The network relationships property returns a set of relationship objects in the network object.

The following query expression will return a set of relationship objects used in the network object.

$NETWORK_BS.relationships

The network role property returns the extended link role object of the network object.

The following query expression will return the role object used for the network object.

$NETWORK_BS.role

The network roots property returns a set of concepts representing the root concepts of the network object.

The following query expression will return the concept objects representing the root concepts in the network object.

$NETWORK_BS.roots

3.1.10 Role Object

The role object is used to define an XBRL role.

The query expression below defines the role of the Balance Sheet in the US-GAAP-2020 taxonomy object using the network role property.

constant $NETWORK_BS_ROLE = $NETWORK_BS.role

3.1.10.1 Role Object Properties

The role uri property returns the role uri as a string.

The following query expression will return the uri of the role object.

$NETWORK_BS_ROLE.uri

The role description property returns a string that represents the description of the role object.

The following query expression will return the description of the role object.

$NETWORK_BS_ROLE.description

The role used-on property returns a set of QNames of the extended link element names the role is used on.

The following query expression will return a set of Qnames representing the use-on property of the role object.

$NETWORK_BS_ROLE.used-on 

The role all-references property returns a set of all reference objects associated with the role.

The query expression below returns a set of all references for $NETWORK_BS_ROLE.

$NETWORK_BS_ROLE.all-references

3.1.10.2 Role Object Properties/Functions with Parameters

The role object has the following associated properties that take parameters.

3.1.11 Ext-enum Object

The ext-enum object is used to define an extensible enumeration.

3.1.11.1 Ext-enum Object Properties

The ext-num role property returns the role object of the ext-num object.

The ext-num domain property returns the concept object of the ext-num domain.

The ext-num members property returns a set of concepts linked to the domain concept by the domain-member arcrole.

The ext-num head-useable property returns a boolean that indicates if the domain member is included as an enumeration.

The ext-num enum-version property returns a string representing the version of extensible enumeration used.

3.1.12 Type Object

The taxonomy model uses the XML Schema data-types system [XML Schema Datatypes] for defining the datatype of values. It does not make use of the XML Schema structures system [XML Schema Structures], as this is not relevant outside of the context of an XML document.

A type object represents a data type.

3.1.12.1 Type Object Properties

The type name property of a type object returns the QName of the type, for simple types.

The type enumerations property of a type object returns a set of allowed values for the type.

The type has-enumerations property of a type object returns a boolean if the type is restricted to a list of enumerated values.

The type-ancestry property of a type object returns a list of the data type ancestry.

The parent-type property of a type object returns the type of the parent type.

The base-type property of a type object returns the base type of the type.

The min-inclusive property of a type object returns an integer value of the min inclusive cardinal value for a type.

The max-inclusive property of a type object returns an integer value of the max inclusive cardinal value for a type.

The min-exclusive property of a type object returns an integer value of the min exclusive cardinal value for a type.

The max-exclusive property of a type object returns an integer value of the max exclusive cardinal value for a type.

The total-digits property of a type object returns the integer value of the total digits of a value.

The fraction-digits property of a type object returns an integer value of the number of digits to the right of the decimal place.

The value-length property of a type object returns an integer value of the length of a string value.

The min-length property of a type object returns an integer value of the minimum length of a string value.

The max-length property of a type object returns an integer value of the maximum length of a string value.

The white-space property of a type object returns a string of one of the following: 'preserve', 'replace' or 'collapse'.

The pattern property of a type object returns a single regex expression or a list/set of regex expressions.

3.1.13 Name Object

The name object represents a QName.

3.1.13.1 Name Object Properties

The QName namespace-uri property of a name object returns the uri of the QName as a string.

The QName local-name property of a name object returns the local name of the QName as a string.

3.2 Instance Object Model

The instance object model is comprised of the following components.

3.2.1 Instance Object

The instance object defines the properties of a instance.

The expression below defines an instance object using the instance function (see Section 11.11.3)

constant $WSFS = instance('https://www.sec.gov/edgar/wsfs-20211231.htm')

The object representing the instance called by the processor is referenced using the instance function with no value.

constant $CURRENT_INSTANCE = instance()

3.2.1.1 Instance Object Properties

The instance document-location property returns the document location of the instance object as a uri.

The instance facts property returns a list of facts in an instance. These facts do not have dimensional alignment. The facts property returns all facts including duplicates. This differs from the fact query which removes duplicates.

The instance taxonomy property returns the taxonomy object used by the instance.

3.2.2 Fact Object

The fact object defines a fact. The value of the object defaults to the fact value as a formatted string when output. There is no property that represents the fact value.

3.2.2.1 Fact Object Properties

The fact decimal property returns an integer representing the decimals associated ith a numeric fact. If the fact is a non-numeric fact a none value is returned.

The fact concept property returns the concept object for the fact.

The fact period property returns the period object for the fact. If the fact has a forever period then a none value is returned.

The fact unit property returns the unit object for the fact. If the fact has non-numeric value a none value is returned.

The fact language property returns the language string for the fact. If the fact has a numeric value or no language assigned a none value is returned.

The fact entity property returns the entity object for the fact. If the fact has no entity property a none value is returned.

The fact dimensions property returns a dimensions dictionary associated with the fact. If the fact has no dimensions a none value is returned. The dimensions dictionary is a dictionary object with key value pairs. The dictionary key must be either a dimension concept or QName. The dictionary value must be either a dimension member concept, QName or datatype if a typed dimension.

The fact dimensions-explicit property returns a dimensions dictionary associated with the fact if the dimensions are explicit. If the fact has no explicit dimensions a none value is returned.

The fact dimensions-typed property returns a dimensions dictionary associated with the fact if the dimensions are typed. If the fact has no typed dimensions a none value is returned.

The fact id property returns the fact id as a string. If the fact has no id a none value is returned.

The fact sid property returns the sid associated with the fact. A sid is a semantic identifier based on the concept, unit, period, entity, dimensional qualifications, decimals value and the value of the fact. The sid is defined using a hash. The calculation of the sid hash is processor dependent!

The fact footnotes property returns a set of footnote objects. If the fact has no footnotes an empty set is returned.

The fact instance property returns the instance object that the fact is in.

The fact cubes property returns a set of cubes that the fact is valid in. If the fact is not valid in a cube an empty set is returned.

The fact is-fact property returns a boolean result if the object is a fact object.

The fact is-monetary property returns a boolean result if the fact has a monetary value.

The fact is-nil property returns a boolean result if the fact has a nil value.

The fact namespace-map property returns a set of namespaces defined in the instance document.

3.2.2.2 Fact Object Properties/Functions with Parameters

The fact object has the following associated property that takes parameters.

3.2.2.3 Inline Fact Object Properties

Inline fact properties are included as properties of the fact for facts defined in an inline document. The value of the inline fact properties will return none when an XBRL instance is not in an inline XBRL format.

The fact inline-hidden returns a boolean result if the fact is hidden in the inline document.

The fact inline-scale returns an integer result defining the scale used in the inline document.

The fact inline-format returns a QName result defining the transform that was used for the fact in the inline document. If no transform was used a none value is returned.

The fact inline-display-value returns a string result representing the string value appearing in the inline document.

The fact inline-negated returns a boolean result if the fact is negated in the inline document.

The fact inline-parents returns a list of facts that are parent html nodes of the fact in the inline document. The property navigates continuations in the inline document. If a fact is included in multiple continuations the parents of those continuations are included in the list of parent facts.

The fact inline-ancestors returns a list of facts that are ancestor html nodes of the fact in the inline document. The property navigates continuations in the inline document. If a fact is included in multiple continuations the ancestors of those continuations are included in the list of ancestor facts. When going up the tree, continuations are evaluated for each parent fact and each parent continuation. If a fact is in a continuation that was referenced by another continuation the parent is accessed by traversing back to the source continuation and evaluating parent html nodes of that continuation.

The fact inline-children returns a list of facts that are child html nodes of the fact in the inline document. The property navigates continuations in the inline document. If a fact includes continuations the children of those continuations are included in the list of child facts.

The fact inline-descendants return a list of facts that are descendant html nodes of the fact in the inline document. The property navigates continuations in the inline document. If a fact includes multiple continuations the descendants of those continuations are included in the list of descendant facts. When going down the tree continuations are evaluated for each child fact and each child continuation.

3.2.2.4 Fact through Concept Object Shortcut Properties

The fact all-references property returns a set of all reference objects associated with the concept of the fact.

The fact base-type property returns a base-type of the data-type of the concept associated with the fact. The base-type is represented as a type object.

The fact data-type property returns a data-type of the concept associated with the fact. The data-type is represented as a type object.

The fact enumerations property returns a set of strings derived from the data-type object of the concept associated with the fact. This is a short form of $concept.data-type.enumerations

The fact has-enumerations property returns a boolean derived from the data-type object of the concept associated with the fact. This is a short form of $concept.data-type.has-enumerations

The fact is-numeric property returns a boolean indicating if the QName of the base-type of the concept associated with the fact equals decimalItemType.

The fact name property returns a QName of the concept associated with the fact.

The fact local-name property returns a string representing the localName of the QName.

The fact namespace-uri property returns a string representing the prefix of the QName.

The fact substitution property returns a type object of the substitution group of the concept associated with the fact.

3.2.3 Period Object

The period object defines the period information associated with a fact value in the instance.

3.2.3.1 Period Object Properties

The period days property of a period object returns the number of days in a duration as an integer. Days are calculated where dates are the start of the day. The days property for an instant period will return 0 days.

The period end property of a period object returns the end date of a duration period or the date time of an instant as a date type

The period start property of a period object returns the start date of a duration period or the date time of an instant as a date type.

3.2.4 Duration Object

The duration object represents a start date and end date duration. A duration object can be defined using the duration function.

3.2.4.1 Duration Object Properties

The duration days property of an duration object returns the number of days in a duration as an integer.

The duration end property of an duration object returns the end date time of the duration as a date type.

The duration start property of an duration object returns the start date time of the duration as a date type.

3.2.5 Instant Object

The instant object represents a specific date time. An instance object can be defined using the date function.

3.2.5.1 Instant Object Properties

The instant days property of an instant object returns 0 days.

The instant end property of an instant object returns the date time of the instant as a date type.

The instant start property of an instant object returns the date time of the instant as a date type.

3.2.6 Unit Object

The unit object defines the unit of a fact value in the instance. Only numeric facts can have a unit.

3.2.6.1 Unit Object Properties

The unit denominator property of a unit object returns the xbrl measure of the denominator as a QName. If there is no denominator an empty value is returned.

The unit numerator property of a unit object returns the xbrl measure of the numerator as a QName. If the unit only has a measure and no division the property returns the measure.

The unit id property of a unit object returns the id of the unit used in the instance.

3.2.7 Entity Object

The entity object defines the entity of a fact value in the instance.

3.2.7.1 Entity Object Properties

The entity id property of an entity object returns the id of the entity used in the instance.

The entity scheme property of an entity object returns the scheme of the entity used in the instance.

3.2.8 Footnote Object

The footnote object defines the footnote associated with a fact in the instance.

3.2.8.1 Footnote Object Properties

The footnote arcrole property of a footnote object returns the arc-role of the footnote.

$footnote.arcrole

Returns the arcrole such as http://www.xbrl.org/2009/arcrole/fact-explanatoryFact

The footnote content property of a footnote object returns the content of the footnote. If it is a fact it returns a fact object

The footnote fact property of a footnote object returns a set of facts the footnote relates to.

The footnote lang property of a footnote object returns the language of the footnote.

The footnote role property of a footnote object returns the footnote-role of the footnote.

$footnote.role.uri

Returns the role uri such as http://www.xbrl.org/2003/role/footnote

4 Query Set

A query set represents all the physical components used to query either a taxonomy or instance documents.

The query set includes the following components:

  1. Namespace Declarations
  2. Namespace Group Declarations
  3. Output Attribute Declarations
  4. Function Declarations
  5. Constants
  6. Message Default Language
  7. Assert Declarations
  8. Output Declarations
  9. Query Name Prefix
  10. Query Name Separator

The query set can be defined in one file or be spread across multiple files. The first five components above are global. For example a constant or custom function defined in one file is available to Query blocks defined in a different file.

The last two components defined above are file specific components that streamline the naming of queries.

The files contained with a query set must be defined within a common directory. All the files used to define the query set must be identified using the suffix .xql.

4.1 Namespace Declarations

Namespace declarations are used in order to determine the namespace of QNames. Namespace prefixes are used when defining QNames. The prefixes and the associated namespace uri's are defined in the query set in the following format.

namespace {prefix}={uri}

Namespaces are defined once in the query set and cannot be duplicated.

The example shows the namespace declaration for 'iso4217'.

namespace iso4217 = http://www.xbrl.org/2003/iso4217

The default namespace is declared by excluding the prefix.

The example shows the namespace declaration for the default namespace for the US-GAAP 2024 taxonomy.

namespace http://fasb.org/us-gaap/2024

The namespace uri is not defined as a string.

The namespace prefix must be defined as a simple name.

The namespace prefix must be unique. xbrlqe:NamespacePrefixNotUnique

4.2 Namespace Group Declarations

In some cases it is unknown what the namespace of an element will be. XBRL Query expressions expect to be executed against a given taxonomy, but when queries are run against extension taxonomies unexpected namespaces can arise when different versions of the same taxonomy are used. The namespace group averts this by using QName prefixes that can represent a group of namespaces.

The namespace group declaration maps a single namespace prefix to a list of defined namespaces.

The group of namespaces is provided as a list of string items. A string item MUST be provided in the list. xbrlqe:InvalidObjectType

The string items provided in the list can be a full uri or partial portion of the uri. The processor should match all namespaces that match the full or a partial component of the string.

Multiple namespace groups can be defined in a query set. Each namespace group prefix MUST be unique.xbrlqe:NamespacePrefixNotUnique

The namespace group declaration eliminates the risk of duplicate element name clashes across different taxonomies when local-names are used. It allows a single query set to be defined that can be used across updated releases of a taxonomy which has a time incremented namespace.

The following shows two dei namespaces defined as follows:

    namespace dei = http://xbrl.sec.gov/dei/2021
    namespace dei-2022 = http://xbrl.sec.gov/dei/2022

A namespace group can be defined such as dei-all (Or any name). This is then associated with any namespace containing the string "dei".

    namespace-group dei-all = list('dei')

To define a rule that selects all the fact values for the dei element DocumentPeriodEndDate in the filing the following filter can then be used:

    {@concept = dei-all:DocumentPeriodEndDate}

As opposed to the following:

    {@concept.local-name = 'DocumentPeriodEndDate'}

Multiple namespaces can be included in the list of allowable namespaces by providing them as strings in the list.

A namespace group MUST not be declared in the fact query. NamespaceGroupDeclarationInFactQuery

A namespace group prefix MUST only be used in a fact query expression. NamespaceGroupPrefixNotInFactQuery

4.3 Output Attribute Definitions

The query set can contain a user defined Output Attribute that is associated with the output of a query. This is useful for classifying rule types for applications. Output attributes allow for refinement on severity levels or additional details that would otherwise have to be extracted from a message string.

Output attributes are defined using the output-attribute declaration as shown below:

output-attribute myQueryAttribute

The output attribute defines an attribute called myQueryAttribute. This can then be defined at the bottom of a query block.

The output attribute is unique and duplicate definitions must not be defined. If a duplicate is defined the error xbrlqe:DuplicateOutputAttributeDefined is returned.

Predefined output attributes are included called message, query-suffix, query-focus and severity that are not defined using an output attribute declaration.

In addition to predefined output attributes, the query language includes output attributes that supports exporting information to a file. The attribute file-content defines the content that will be output. This is defined as a string and can be derived from the to-json, to-csv, to-spreadsheet or string properties. The content MUST not contain objects.

The output attribute file-location defines the location where the file content is written to. Multiple output queries can be written to the same file. To prevent the existing content from being overwritten the output attribute file-append can be used with a boolean value to indicate if content is appended or overwritten. The value of file-append MUST be true or false.

The following example will output the values of PropertyPlantAndEquipmentNet on separate rows of a spreadsheet for each value in the tab called PPE. The file location attribute indicates the location where the file should be saved. The file-content attribute indicates the content to be writtem and the file-append attribute that each iteration of the rule should append to the existing file.

output ppe-spreadsheet

      $spreadsheet = dict(list('PPE', list('Property Net',[@PropertyPlantAndEquipmentNet]))).to-spreadsheet

      true
else
    skip

file-location '/output/ppe.xlsx'
file-content $spreadsheet
file-append true

4.4 Custom Function Definitions

A Custom function can be used when queries repeat the same logic. Rather than duplicating the query logic, a custom function can be defined and used by multiple queries. Custom functions allow the passing of values to the function and returning the results from the function. Variables or tags defined within the function are available to use in a query output such as a message. Functions are defined with the keyword function.

Function names must be defined as a simple name.

Dimensional alignment of facts is maintained when using a function.

Recursive functions are not supported by the processor.

Functions do not have to have arguments.

The example shows a function with no arguments that returns a set.

function non_neg_concepts()
set(Assets, Liabilities)

The railroad diagram in Figure 3 shows the components of an Custom function declaration.

Figure 3: Function Declaration

function FunctionName ArgName FunctionBody

4.5 Constants

A constant is a global variable defined as part of the query set but not included in the query block.

Example constant declaration

constant $hello = 'hello'

4.6 Message Default Language

The message-language keyword is used to identify the default language used for messages. If no message language is defined it defaults to English. The message language can be specifically be defined as part of the message.

The example shows setting the default message-language to french.

message-language "fr"

4.7 Query Blocks

Queries are defined in blocks called a query block. Query blocks have a specific structure depending on the query type. A query can either be defined as an assert query or as an output query.

Assert queries are used to define a rule and must evaluate to a boolean result. The keyword assert is used to identify a query as an assertion.

The railroad diagram in Figure 4 shows the components of an assert declaration.

Figure 4: Assert Declaration

assert satisfied unsatisfied Expr QueryResult

Output queries are used to return data from an XBRL instance, XBRL taxonomy or both. The keyword output is used to identify a query as an output.

The railroad diagram in Figure 5 shows the components of an output declaration.

Figure 5: Output Declaration

4.7.1 Parts of a Query Block

Query Parts are those components that make up a query block.

Assert and output queries are composed of the following parts.

Part Query Type Required Example Details
Assert declaration Rule TRUE assert The keyword assert identifies the query expression as an assertion that resolves to true or false.
Output declaration Data TRUE output The keyword output identifies the query expression as an output that can return any query value.
Query Name Rule or Data TRUE abc.0001 The unique identifier of the assertion or output.
Assertion Type Rule TRUE satisfied A rule assertion type can be satisfied or unsatisfied. If not defined the default is satisfied. The satisfied keyword returns a result if the expression is satisfied. The unsatisfied keyword returns a result if the expression is not satisfied
Query Expression Rule or Data TRUE exists({@ where $fact < 0 }#nonnegitem) The defined expression that defines a true or false result for an assertion. The value must resolve to a boolean result to be a valid assertion. An output expression is not restricted to the value returned.
Query Message Rule TRUE "The value of {$nonnegitem.concept.name} is less than zero." The message component is a string used to report information from the assertion result. All variables calculated in the performance of the assertion can be inserted into a message string using curly brackets.
Query Message Data False A message is not required for an output but can be used in the same manner as an assertion.
Severity Rule FALSE error Defines the severity of the assert query. The severity keyword will default to error if not defined. Severity has the following enumerated values: error, warning, ok or pass. The severity can be defined as a string or a variable.
Query-focus Rule or Data FALSE $nonnegitem Returns semantic and syntactic information about the query that can be used by software to indicate where the error occurred in the XBRL instance. The Query-focus is provided as a variable. The rule focus must evaluate to a fact, facts, a concept or concepts. The inclusion of this component is optional. The processor will default to the first fact in the expression when processing the rule if a rule focus is not provided.
query-suffix Rule or Data FALSE $nonnegitem.concept.name.local-name Used to add a suffix to a rule. The query-suffix can be passed as a literal or a variable allowing variable names to be defined at run-time. A single rule can generate rule results with different rule numbers depending on the input to the query.

4.7.1.1 Query Declaration

The query declaration part of a query block must use either the keyword assert or output. These keywords are case insensitive. The query declaration is the first part of the query. The declaration indicates if the query is an assert query or an output query.

4.7.1.2 Query Name

The query name is the second part of the query block. The query name must be defined as a NCname. The query name must be unique across the entire query set. Query names are often called rule names.

4.7.1.3 Query Assertion Type

The assertion type is the third part of the query block. The assertion type can have a value of satisfied or unsatisfied or be blank. The assertion type must be blank for an output query. If not defined for an assert query the default is satisfied. The satisfied keyword returns a result if the expression is satisfied. The unsatisfied keyword returns a result if the expression is not satisfied

4.7.1.4 Query Expressions

Query Expressions are comprised of local variables, tagged values, block expressions, fact queries, navigate queries, properties, functions, literals and operators to produce a query result. For an assert query the query expressions must return a true or false result. An output query is not restricted to the type of the value returned. A query expression can use any of the grammar defined in the query specification.

4.7.1.5 Query Result

The results of a query is called a query result. The query result can have five possible components. The railroad diagram in Figure 6 shows the components of a query result.

QueryResult

Figure 6: Query Result

4.7.1.5.1 Query Message

The query message is defined using the keyword message. The query message can be any expression that is converted to string when output to report information from either an assert or output query. The query message cannot create iterations. All variables calculated in the query expression can be inserted into a message string using a curly bracket substitution.

A message is required for an assert query. A message is not required for an output query.

Within a query expression tagged values can be defined using the # character. The name of the tag must succeed the # character.

In the following example the fact object of assets is tagged with #a

{@concept = assets}#a

The value and properties of # tags can be referenced in the query message. Any values in a query expression can be tagged. This includes the contents of custom functions.

Tagged values, local variable names and expressions can be inserted into message strings using the curly bracket substitution syntax. Any expression can be defined in curly brackets within a message to report local variable values or tagged values that were defined as part of the iteration.

Curly brackets are used in the message below to report the value of assets. The tag #a is defined as $a in the message. Because $a is a fact, the properties of the fact can be returned in the message using the dot notation.

output AssetValue
    {@concept = Assets}#a 

message
    "The value of {$a.concept.name} is {$a}"

The value of the query expression is recorded in a variable called $rule-value. If a rule evaluates to a boolean of true, then the value of $rule-value will be recorded as 'true'. The $rule-value variable can be used in a message to indicate the result of an output or the result of running the rule.

For example the result of an output value can be reported using $rule-value.

output add-two-numbers
    @assets#a + @liabilities#b

message
    "{$a} +  {$b} = {$rule-value}"
4.7.1.5.1.1 Message Language

The default language used for messages is set using the message-language keyword. To output messages in a different language a language string is defined after the message keyword using the following format:

message "BCP 47 language code"

The string MUST be a valid BCP 47 BCP47 language code oime:invalidLanguage.

For example to define a message in French the language attribute is defined as a string value based on BCP 47 language codes.

    message "fr"  

    "message en français"

The language code can be evaluated as an expression that resolves to a string.

Multiple messages can be defined in different languages.

4.7.1.5.2 Query Severity

The severity part is defined using the severity keyword. The severity keyword is case insensitive Severity can be used with the assert and output query. The severity is used to indicate the severity of a rule result. Severity must have the following enumerated values: error, warning, ok or pass. The severity can also be defined as a variable or an expression that resolves to a string with a value of error, warning, ok or pass. The allowable enumerated values are case insensitive. If a severity message other than error, warning, ok or pass is defined then an error of xbrlqe:InvalidSeverityValue is returned.

The following example shows setting the severity dynamically.

assert myerror satisfied

$error = 'warning'
true

message
"This is an error."

message "fr"
 "C'est une erreur"

error $error
4.7.1.5.3 Query Focus

The query-focus returns semantic and syntactic information about the query that can be used by software to indicate where the data used in the query expression was located in the XBRL instance. The query-focus value is provided as a local variable. The rule focus must evaluate to a fact, facts, a concept or concepts. The inclusion of this component is optional. The processor will default to the first fact in the expression when processing the rule if a rule focus is not provided. The format of the results returned by query focus is processor dependent.

4.7.1.5.4 Query Suffix

The query-suffix is used to add a suffix to a query name. The query-suffix can be passed as a literal or a variable allowing variable names to be defined at run-time. A single query can generate query results with different query names depending on the input to the query. The query-suffix is concatenated to the end of the rule name using a period as a separator. The separator character can be changed using the query name separator declaration.

4.7.1.5.5 Output Attribute Value

An output attribute value can be added as a query part. The output attributes are defined as part of the output attribute declarations component of the query set. The values to be returned for each of these attributes is defined as part of the Query block. Output attributes must be returned as strings.

4.7.2 Example Queries

The assert query below returns a value of true for fact values less than zero. Any value less than zero will return a message with a severity of error. The query-focus will return details of the negative fact. The query-focus details are processor dependent. The output attribute value of myAttribute is also used to return the values of decimals as a value that can be reported in a log file.

assert abc.0001 satisfied

exists({@ where $fact < 0 }#nonnegitem)

message 
"The value of {$nonnegitem.concept.name}  is equal to {$nonnegitem} for the period {$nonnegitem.period}. Please make the value positive.'"

severity error
query-focus $nonnegitem
query-suffix $nonnegitem.concept.name.local-name
myAttribute $nonnegitem.decimals.string

The output below returns the fact that was negative.

output abc.0002 

{@ where $fact < 0 }

4.8 Query Name Options

The query name prefix declaration is used where query names have a common prefix naming convention. A common prefix can be defined for all queries in the same file. The keyword query-name-prefix is used to set a standard prefix for all rules in the file where the declaration is defined. When query names are defined the prefix does not need to be included.

The query name prefix must appear preceding the queries in the file that it is intended to apply to. Multiple query name prefix can be defined in a file. Any queries after the declaration of the query name prefix will use the later prefix.

query-name-prefix my_rules

The Query name separator declaration is used to change the separator added by query-name-prefix`` andquery-suffix`. To change the separator from the default period to a colon the following declaration is made.

query-name-separator ":"

4.9 Compiling the Query Set

A query set zip file contains the compiled query set components in a zip file format. The query set zip file is not normative.

A query set zip file MUST conform to the [.ZIP File Format Specification][ZIP] (rpe:invalidArchiveFormat or tpe:invalidArchiveFormat).

5 Query Expressions

The query expression defines the logic of the query. The query expression must resolve to an iteration with a result or a non binding iteration. The query expression can comprise the following components:

5.1 Literals

A literal represents strings, numbers , QNames and keywords.

5.1.1 String Literal

Strings are represented using either a single quote or double quote. Valid characters for a string is utf-8 characters.

5.1.1.1 Escape sequences in strings

The following escape characters are supported to allow values in strings to be escaped.

Character Defined As
Quote \"
tab \t
return \n
Curly Bracket \{

5.1.1.2 Substitute an expression in a string

Curly bracket substitution allows strings to be formatted with a query expression. Curly brackets are defined in the string and contain the query expression. Curly brackets can be used in a message but must be escaped.

5.1.2 Numeric Literals

Float and integer literals are supported. An integer can have an optional sign followed by numbers. No whitespace between the sign and the number is used to represent the sign. To define a number as a float it must include a decimal point. Floating numbers can include scientific notation.

Formatting of floats must include a decimal point and at least 1 digit. No digits have to follow the decimal point. No digits need to precede the decimal point. When using scientific notation there must be at least 1 digit to the right of the decimal point, which can be zero.

The following are valid floats

5.1.2.1 Inf literal

The inf literal represents a floating number. Inf is commonly used to represent infinite decimals of a fact. Inf can also be used to represent an infinite number. Inf is case-insensitive.

The following example will return a value of inf. The processor considers inf as a floating number.

max(list(inf,1,2,3))

5.1.3 Period Type Literal

The period type can have literal values of either duration or instant. These are not defined as strings in an expression but are evaluated to a string. The evaluated string value is case sensitive. (lower case). The literal value is case insensitive.

5.1.4 Balance Type Literal

The balance type can have literal values of either credit or debit. These are not defined as strings in an expression but are evaluated to a string. The evaluated string value is case sensitive. (lower case). The literal value is case insensitive.

5.1.5 Severity Type Literal

The severity type can have literal values of either error, warning, ok or pass. These are not strings and are case insensitive.

5.1.6 Boolean Type Literal

The boolean type can have literal values of either true or false. These are not strings and are case insensitive.

5.1.7 Forever literal

Forever defines a duration object of unlimited length. It also represents periods that have no period. The literal is case-insensitive. Forever is not defined as a string in an expression and is evaluated as a forever duration. The literal value is case insensitive.

The following example will return all facts that have a period of forever.

{@period = forever }

5.1.8 QName Type Literal

The Qname type must have literal values that represent QNames. These can be prefixed or un-prefixed.

5.1.9 Tagged Expressions

The # tag is used to associate the value before it with a tag immediately after it. The tag must be a simple name, and is case sensitive. The tag can then be used as a variable in any query output such as the query message using a $. The tag must not be referenced in the body of the query.

The following example is incorrect as the tag is referenced as a variable in the body of the query.

$ValueOfAssets = 20#Assets

30 + $Assets

5.1.10 Index Expressions

An index expression is used to retrieve data from a list or a dictionary. The index is represented using a square bracket notation.

For a list the square brackets indicate the location in the list. Items in a list start at 1. To retrieve data from a list the index expression must be an integer greater than or equal to 1. If the integer is larger than the length of the list or has a value less than 1 then an xbrlqe:IndexValueOutOfRange error must be produced.

The following example shows the index expression using an integer of 2 to return the value of 'b' from the second location in the list.

list('a', 'b', 'c')[2]

There is no space between the [] and the end of the list.

For a dictionary the square brackets indicate the key of the key value pairs in a dictionary. If the index item does not appear in the dictionary then a none value is returned. The value of the key can be any type of object.

The following example shows the key QName value of Assets returning the value of 'a QName' from the dictionary

dict(list('0', 'zero string'), list(Assets, 'a QName'), list('a', 'a string'), list(0, 'zero number'))[Assets]  

There is no space between the [] and the end of the dictionary.

If an index expression is used, on anything other than a list or dictionary then an xbrlqe:IndexNotOnListOrDictionary error must be produced.{#index-op-set-error}

5.1.11 Unary Characters

The unary characters of + or - can be used in front of a number to reverse the sign of a number or an expression.

The following shows how the operator reverses the sign. - 10 = -10

-(10 + 2) = -12

5.1.12 Other Literals

The following additional literals can be used:

These literals are not case sensitive.

5.2 Local Variable Definitions

All local variables are defined using a simple name.

A simple name is based on a NCname. A simple name extends the NCname by excluding the use of '.' in the name.

A local variable is used to store values within a single iteration of a query.

A local variable can be defined within a query expression.

A local variables type is not defined.

A local variable can represent any object in the Query Data Model

A local variable can represent a set, list or dictionary.

A local variable is assigned using the = operator or the in operator when used in a for loop.

A local variable is dynamically typed based on the value or object.

A local variable name is prefixed with a $ sign.

An expression defining a local variable should be concluded with a ;.

A local variable if reassigned within the scope of a processing iteration must follow the variable order of precedence.

Local variable values are not stored across processing iterations.

Example local variable declaration in a output query

output abc.0003
$hello = 'hello';
$hello

5.3 Variable Order of Precedence

The same local variable can be defined multiple times.

Variables can be set in a number of ways and it may not be clear which value is assigned to variables with the same name. Variables can be defined by a constant, as an argument to a function, as part of a for loop or direct assignment to a variable.

A constant cannot have the same name as another constant but a local variable or function variable can. The constant has a lower order of precedence than a local variable or function variable if they have the same name.

For example:

$a = 10;
$a = 20;

The expression assigns a value of 10 to the variable $a and subsequently assigns a value of 20 to a second variable called $a. The value of $a will return 20 as the last variable defined takes precedence.

The function test() is defined as follows:

function test($a)
$a = 30;
$a

This function will always return a value of 30, irrespective of the value passed to the function.

The following shows an example of the interaction of constants and functions.

A constant of $a is defined as part of the query set with a value of 40.

constant $a = 40

The test function from above is called and is passed a value of 20.

$a = test(20) + $a

The resulting value of $a will be 70. (30 + 40)

Constants can be referenced in a function but the value will be superseded by the argument to the function and this will be superseded by direct variable assignment in the function.

If the test function was defined as follows:

function test($a)
    $a

The test function is passed as a value of 20.

test(20) + $a 

The resulting value of $a will be 60. (20 + 40)

If the test function was defined as follows:

function test($b)
    $a

The test function is passed as a value of 20.

test(20) + $a

The resulting value of $a will be 80. (40 + 40). The value of the constant is used for $a.

5.3.1 Reserved Variables

The following variables are reserved for use when using a where clause expression:

5.4 Iterative Statements (For Loops)

A for loop is used to iterate through a set or list of values. A for loop is defined using the keyword for.

There are a number of objects and properties that returns sets and lists that use the for loop to access the values. These include the following: - Network relationships property - Concept all-references property - Reference parts - Taxonomy networks property - Taxonomy concepts property Or any other set or list.

The for loop has the following structure:

for (variable in (set|list))
    Repetend

Where repetend is the expression to be repeated. For loops do not define how many times the loop should execute. The for loop will repeat until it gets to the end of the set or list. The set or list can be entered as a variable or as an expression. The for loop must loop through a set or a list. Any other object will cause the error xbrlqe:InvalidForLoopObject.

The variable declaration in the for loop is defined as a local variable and must follow the constraints of defining a local variable.

For example this for loop evaluates the taxonomy().concepts to a list of all concepts in the taxonomy. The for loop then iterates through each concept and returns the QName of each concept in the taxonomy. The loop will be repeated for every concept in the taxonomy.

for ($c1 in taxonomy().concepts)
    $c1.name

The results of a for loop can be returned as another set by defining a variable.

For example this for loop evaluates the taxonomy().concepts to a list of all concepts in the taxonomy. The for loop then iterates through each concept and returns the local name of each concept in the taxonomy and adds it to a set called $string_name_of concepts.

$string_name_of_concepts = set(for ($c1 in taxonomy().concepts)
                    $c1.name.local-name)

A for loop can be used in the definition of a constant.

The same variable name must not be used where a for loop is contained within another for loop.

5.4.1 Assigning Local Variables in For Loops

A local variable can be declared by looping through a list or a set.

The example shows how the variables initiated by the for loop can be used in a message.

for $a in list('a', 'b')
        for $b in list('x', 'y')
            1
message '{$a} {$b}'

Returns 4 iterations of messages:

    'a x'
    'a y'
    'b x'
    'b y'

5.5 Conditional Statements (If-else statements)

An If-else statement is used to define conditional statements.

The if-else statement has the following form:

if ( condition ) statement1 else statement 2

The condition is a boolean expression. The condition MUST resolve to a boolean result. xbrlqe:InvalidObjectType

If the condition resolves to a value of none, the iteration is skipped.

Both the statement1 and statement 2 need to be included in the if-else statement.

The following example will return a true condition if the amendment flag in the default is set to true and there is no amendment description anywhere in the filing. If either of these conditions are false then the else statement returns false.

if ([@dei:AmendmentFlag] == true and count(list({covered @dei:AmendmentDescription})) == 0))
    true 
else
    false

If the else statement is to do nothing then the keyword none should be used or the iteration can be skipped using the skip keyword. The else statement must be included to indicate the end of the if condition.

The if-else statement condition can be encapsulated in parentheses.

An if statement can be included in a for loop.

For example, for loops and if-else conditions can be combined to filter a list or set.

As the for loop iterates through a set of values the if statement is used to filter items out of the set based on the if condition. In a fact query the where clause is used to perform the same function.

The for expression below returns 'b' and 'c' in separate iterations.

for $x in set('a','b','c')
    if $x == 'a'
        false
    else
        true

5.6 Filtering Collections

The filter expression is used to filter a set or a list. A filter returns a set or a list depending on the collection type passed to it.

The filter expression MUST be passed a set or list to filter. If an object other than a set or list is used the xbrlqe:InvalidFilterExpression error is returned.

The railroad diagram in Figure 7 shows the components of a filter expression.

Figure 7: Filter Expression

Filtering a set $a will return set $a.

filter $a

The filter expression uses a where clause to filter the list or set based on a boolean condition. The where clause uses the $item variable to represent the current value in the set or list.

The $item variable is used to identify those items in the set that are greater than 1. This returns set(2,3)

filter set(1,2,3) where $item > 1

The values returned by the filter are specified by using the keyword returns. If returns is left off the values from the set not removed by a where clause are returned. The $item variable can be used in the returns expression.

For example if QName concepts are in a set these can be turned into local names using the filter expression returns keyword. The $item variable can be used as part of the filter return expression as shown below:

filter $networkQname returns $item.local-name

The filter expression returns a set of local names from the set of QNames defined in the variable $networkQname.

The filter expression MUST return an error when an object other than a set of list is filtered. xbrlqe:InvalidFilterExpression - Filter expression can only be used on a 'set' or 'list'.

The returns expression can incorporate strings to build up text based output.

(filter $sub-periods returns "\t" + $item.period.string + "\t" + $item.string).join("\n");

This returns a string value showing the period of the item and the item separated by tabs and ended with a carriage return.

Filter expressions can be nested inside other filter expressions. The $item variable remains local to the filter expression being referenced.

This example shows nesting a filter and the $item variable being used local to the filter expression. The inner most filter is resolved first.

    filter (filter set(1,2,3,4) where $item > 1) where $item < 4

This returns set(2,3)

6 Fact Queries

To select a set of facts for evaluation a fact query is defined as part of the query. The railroad diagram below in Figure 8 shows the components of a fact query body.

The fact query will return XBRL facts defined as Facts, but excludes fact footnotes. These are facts with the concept name of note. These facts are queried using the footnote object properties.

FactQueryBody:

Figure 8: Fact Query Body

The fact query consists of components to control dimensional alignment (covered and covered dims), dictate the handling of nils, define dimension filters and define the where clause. These are combined to select facts from the XBRL instance.

The dimension filter is a component of the fact query body that defines the value of a dimension to match a fact. The dimension filter defines the dimension, an operator and a matching value called a dimension expression. The dimension filter is comprised of the components described in Figure 9 below.

Figure 9: Dimension Filter

All dimension filters in a fact query are prefixed with either the @ or @@ character. This indicates that the subsequent string is a dimension name.

The dimension filter expression has the following form:

@[Dimension Name] [operator] [Dimension Expression]

The operator and dimension expression are optional.

The operator must be one of the following: =, !=, in, not in

The dimension name is used to define the dimension of a fact to select on. The dimension name can be the dimension and/or the dimension properties. The dimension name values of the dimension filter must be one of the values described in Figure 10 below.

DimensionName:

Figure 10: Dimension Name

Dimension names must only appear once in a fact query.

A dimension name is comprised of the dimension and/or its dimension properties. The following represents different dimension names.

@concept.balance
@concept.period-type

If a dimension name is defined that is not in the above list or has a property that is not defined for the dimension name then the error xbrlqe:InvalidDimensionName is returned.

The Dimension Expression defines the object or QName of an explicit dimension or a value of a typed dimension. The expression must resolve to the type expected by the dimension name. When the in or not in operator is used the dimension expression can be a set or a list containing values with a type matching the dimension name. When the dimension dictionary filter is used the dimension expression must be a dictionary.

6.1 Concept Filters

A concept filter is a type of dimension filter that filters facts based on the concept core dimension. The concept filter is defined within a fact query.

The concept filter has a shortcut that allows the @ symbol to be provided with a QName immediately following the @. This shortcut eliminates the string '@concept ='

The concept filter @concept = Assets is the same as @Assets.

XBRL facts can be filtered based on the concept object and specific concept properties defined below. The table defines the allowable concept filters.

Filter by Property Description Example
Concept concept or QName or * or none Can be either the concept object or the concept QName. The value can also be a wildcard *, none or an empty value. {@concept = $Assets}
{@concept = Assets}
{@concept = *}
{@concept = none}
{@concept}
Name QName Must be the QName of the concept or a * for a wildcard. {@concept.name = Assets}
{@concept.name = us-gaap:Assets}
Local Name local-name Must be local name of a concept defined as a string or *. {@concept.local-name = 'Assets'}
Period Type period-type Must be instant or duration as a period type or *. {@concept.period-type = instant} {@concept.period-type = duration}
Balance balance Must be credit or debit as balance type or a * or none. (* will return all concepts with either a balance of credit or debit) {@concept.balance = debit}
{@concept.balance = credit}
{@concept.balance = none}
{@concept.balance = *}
Custom attribute attribute(name) Custom attribute value, Value, * , none (* will return all concepts with any attribute value associated with the concept ) {@concept.attribute(someAttribute) = *}
Data type data-type Must be a data type of the concept as a QName {@concept.data-type = xbrli:monetaryItemType}
Base type base-type Must be a base data type of the concept as a QName {@concept.base-type = xbrli:stringItemType}
Has enumerations has-enumerations Boolean value to select concepts with or without enumerations. {@concept.has-enumerations = true}
Substitution group substitution Concept schema declared substitution group. {@concept.substitution = xbrli:item}
Namespace namespace-uri URI of concept namespace. {@concept.namespace-uri = 'http://xbrl.sec.gov/dei/2024-01-31'}

6.1.1 Selecting Collections

All of the selectors listed above can also be used with a set or a list using an in operator.

{@concept in list(Assets, Liabilities)}

6.1.2 Converse Selections

To select facts not matching a concept the != operator is used. To select all items not in a list the not in operator is used.

The example below selects all concepts that are not Assets

{@concept != Assets}

To exclude multiple concepts the not in operator is used with a list containing the QNames Assets and Liabilities.

{@concept not in list(Assets, Liabilities)}

Only the = , != , in, and not in operators are used in a concept filter for a fact query .

Multiple concept filters can appear in a fact query. Multiple concept filters are treated as an and condition. The following query returns those facts where the concepts are an instant and have a debit balance attribute.

{@concept.period-type = instant @concept.balance = debit}

6.2 Period Filters

A period filter is a type of dimension filter that filters XBRL facts based on the period core dimension.

Filter by Property Description Example
Period default A period expression i.e. forever, date('2026-12-31'), duration('2016-01-01','2016-12-31'), * {@period = date('2026-12-31')}
Period start start Date and time values to match start for a durational period. If the fact is an instant, the period.end or period.start will return the same date value. {@period.start = date('2026-12-31')}
Period end end Date and time values to match end for a durational period. If the fact is an instant, the period.end or period.start will return the same date value. {@period.end = date('2026-12-31')}
Days days Specify duration of time in days to return values that match that period. {@period.days = 31}

Multiple period filters can be defined in the fact query.

{@period.start = date('2026-01-01') @period.end = date('2027-12-31')}

Facts without a period dimension are filtered using the forever function or none.

{@period = forever} 

Use filter value of 'none' to return facts without a period.

{@period = none} 

To take the period dimension out of alignment, the @period without an operator or value is used.

{@period} 

To take the period dimension out of alignment, without selecting forever periods the * value can be used as the filter value.

{@period = *} 

Allowable period values are a list, a set, a variable, a date, a duration, *, none, forever or no value.

6.3 Unit Filters

A unit filter is a dimension filter, that filters XBRL facts based on the unit core dimension.

Filter by Property Description Example
Unit No property A unit object. For single measure units the QName of the measure. {@unit = xbrli:pure}

The dimension name of the unit filter can either be the QName or the unit object.

The numerator and denominator properties of a unit cannot be used as apart of the <.

A unit object can be defined using the unit function. The expression below creates a USD/Shares unit object, that can be used to filter facts.

{@unit = unit(iso4217:USD, xbrli:shares)}

To select facts with a unit the * wildcard can be used as the filter value.

{@unit = *}

To select facts without a unit the keyword none can be used as the filter value.

{@unit = none}

To take units out of alignment the unit dimension filter can be used with no value. This will select all facts with units and without units.

{@unit}

Allowable unit values are a list, a set, a variable, a unit, *, none, or no value.

6.4 Entity Filters

An entity filter is a dimension filter, that filters XBRL facts based on the entity core dimension.

Facts can be filtered on the following components of the entity object.

Filter by Property Description Example
Entity no property Entity identifier provided as an entity object using the entity function or variable from another fact. The * wildcard can be used to get all entities. A filter value of none can be used to return facts with no entity. {@entity = entity('http://www.xxx.com','0000320193')}
{@entity = *}<br>{@entity = none}
Scheme scheme Uri of the scheme as a string. {@entity.scheme = 'https://www.xxx.com'}
Identifier identifier Identifier of the entity as a string. {@entity.id = 0000320193}

An entity object can be defined using the entity function. The expression below creates a a entity object, that can be used to filter facts.

{@entity = entity('http://www.xxx.com','0000320193')}

To select facts with an entity the * wildcard can be used as the filter value.

{@entity = *}

To select facts without an entity the keyword none can be used.

{@entity = none}

To take entity out of alignment the entity dimension filter can be used with no value. This will select all facts with and without the entity dimension.

{@entity}

Allowable unit values are a list, a set, a variable, an entity object, *, none, or no value.

6.5 Taxonomy Defined Dimension Filters

There are two types of taxonomy defined dimension filters. The first is the taxonomy dimension filter. The taxonomy dimension filter is a dimension with a domain member or typed value paired with a dimension, expressed as dimension = member.. The second is a dictionary of dimensions with a domain member or typed value pairs. This is called a dimension dictionary filter.

6.5.1 Taxonomy Dimension Filter

Filter by Property Description Example
Dimension member (Explicit Dimension) No Properties Value of the dimension member which is either a QName, a variable, *, none or empty. This is used for an explicit dimension. {@dei:LegalEntityAxis = ParentCompanyMember}
{@dei:LegalEntityAxis = *}
{@dei:LegalEntityAxis = none}
{@dei:LegalEntityAxis}
Dimension Value (Typed Dimension) No Properties Value of the typed dimension can be a value matching the axis type, * or none {@RevenueSatisfactionStartDateAxis = date('2027-01-01)}

To return all facts using a specific dimension the wildcard * is used with the dimension name. This does not return facts with no dimensions as the default dimension member is not included in the wildcard.

The wildcard returns facts that have additional dimensions in addition to the defined dimension name.

The example shows the LegalEntityAxis dimension with a *.

{@dei:LegalEntityAxis = *}

To select facts without a dimension the keyword none can be used.

{@dei:LegalEntityAxis = none}

The expression above can also be written as:

{@dei:LegalEntityAxis != *}

To take the dimension out of alignment the dimension filter can be used with no value. This will select all facts with the taxonomy defined dimension as well as facts with the default dimension member. This will exclude facts with other taxonomy defined dimensions.

The example will select all facts with the dei:LegalEntityAxis and facts with no dimensions.

{@dei:LegalEntityAxis}

6.5.2 Dimension Dictionary filter

The dimension dictionary filter has a dimension expression that is a dictionary. The keys of the dictionary are the taxonomy defined dimensions, the values are the taxonomy defined domain members or typed members defined in the instance.

The dictionary can contain typed and explicit dimensions.

The dictionary value associated with the key must be a domain member or a typed value. The value of the typed dimension member must match the type of the typed dimension.

The in and not in comparison operators must not be used with dimension dictionary filter and a dimension expression in a list or a set.

Where the number of and nature of the taxonomy defined dimensions is not known in advance a dictionary of dimension member pairs can be passed to the filter using the dimensions filter.

    $Assets = {@Assets}.dimensions;
    {@concept = Liabilities @dimensions = $Assets}

The expression returns all facts for Liabilities that have the same taxonomy defined dimensions as the fact value for $Assets. These dimensions will be taken out of alignment. The expression selects facts that have the same dimensions as $Assets and any additional dimensions.

To keep values in alignment and use the dimensions filter as a method to filter facts and maintain alignment a @@ can be used in front of the taxonomy defined dimensions filter.

    $Assets = {@Assets}.dimensions
{@concept = Liabilities @@dimensions = $Assets}

The dimensions filter only applies to taxonomy defined dimensions.

The dimensions filter does not include the period, concept, entity or unit dimensions.

The dimensions filter is overridden by any explicit taxonomy defined dimension filters defined in the fact query expression that conflict with the values defined in the dimensions filter.

Only one taxonomy defined dimension filter can be defined in a fact query.

To cover all dimensions in a manner similar to the covered-dims keyword the taxonomy defined dimension filter with no dictionary value can be used.

    {@concept = Liabilities @dimensions}

This is equivalent to the following:

    {covered-dims @concept = Liabilities}

The taxonomy defined filter can be defined with a wildcard to select facts that have taxonomy defined dimensions. This excludes any facts in the default dimension.

The following example shows the use of the wildcard.

    {@concept = Liabilities @dimensions=*}

This will return all facts for Liabilities that have a dimension and member defined.

The taxonomy defined filter can be defined with a none value to select those facts that have no taxonomy defined dimensions. This will include only those facts in the default.

The following example shows the use of the dimensions equal to none.

    {@concept = Liabilities @dimensions=none}

This will return all facts for Liabilities that have no taxonomy defined dimensions.

This is equivalent to the following:

    [@concept = Liabilities]

Specific taxonomy defined dimensions can be used with the dimensions filter. If they conflict, the named dimension takes precedence. If the dimension filter equals none, an additional filter is not considered a conflict.

The following example shows the use of the dimensions equal to none and a second taxonomy defined dimension.

    {@concept = Liabilities @dimensions=none @dei:LegalEntityAxis = *}

This will return all facts for Liabilities that only have the LegalEntityAxis as a dimension on the fact. This is the equivalent to:

    [@concept = Liabilities @dei:LegalEntityAxis = *]

6.6 Cube Filter

A cube filter selects facts that appear in a hypercube. The hypercube can be defined using the cube function by passing the hypercube concept and drs role as parameters to identify the hypercube.

Cubes can also be specified by the hypercube concept name, the drs role of the cube or both. This selection below returns all facts associated with cubes named StatementTable.

{@cube.name = StatementTable}

Facts in a cube can also be specified by defining the drs role.

{@cube.drs-role = BalanceSheet}

This returns facts in the cubes in drs role BalanceSheet.

Using @cube has no effect on the alignment of the returned facts. @cube is only used to filter facts for a fact query .

To return all facts associated with any cube use one of the following:

{@cube != none}

{@cube = *}

To return all facts not in a cube use the equal none expression.

{@cube = none}

6.7 Instance Filter

An instance filter selects facts that appear in a named instance object. The instance can be defined using the instance function by passing the instance uri. An XBRL instance is defined as an XBRL report.

The instance filter filters on the instance of the current filing being evaluated. The instance filter> allows multiple instances to be processed simultaneously. If no instance filter is defined then the instance provided to the processor is evaluated.

To add instances an instance object is defined that references the instance.

$wsfs = instance('https://www.sec.gov/edgar/wsfs-20211231.htm')

This loads the wsfs instance into the processor when called.

Fact query selection defaults to the instance document passed to the processor. To select facts from an alternative instance document the fact query selection criteria must reference the instance object.

The example shows referencing a specific instance in the fact query

{@instance = $wsfs}

This returns all the facts from the wsfs instance.

Sets of facts may be returned from multiple instances using a list of instance objects.

The example shows how multiple instance documents are included in the fact query .

{@instance in list($wsfs, $appl)}

This returns all the facts from the wsfs and appl instances.

The default instance may be specified using instance()

The following example makes the default instance explicit.

{@instance = instance()}

This returns all the facts from the default instance.

Facts from the default and object defined instances may be returned by including instances in a list.

{@instance in list(instance(),$wsfs,$appl)}

This returns all the facts from the default instance and the instance defined by the named variables.

The wildcard and not in selectors are invalid when filtering on the instance dimension.

The following examples are invalid, because there is no defined set of instances.

{@instance not in list(instance(),$wsfs,$appl)}

or

{@instance = *}

6.8 Language Filter

A language filter is a dimension filter, that filters XBRL facts based on the language core dimension.

Filter by Property Description Example
Language No property A language object. The BCP47 language code. {@language = 'fr'}

The dimension name of the language filter must be a BCP47 language code.

The following will select those facts with the french language code.

{@language = 'fr'}

To select facts with a language dimension the * wildcard can be used as the filter value.

{@language = *}

To select facts without a language the keyword none can be used as the filter value.

{@language = none}

To take language out of alignment the language dimension filter can be used with no value. This will select all facts with and without a language dimension defined.

{@language}

Allowable language values are a list, a set, a variable, a unit, *, none, or no value.

6.9 Square and Curly Bracket Control

Facts returned can be controlled using [] characters and {} characters in the fact query.

A curly bracket notation is used to include facts with taxonomy defined dimensions in the fact query.

A square bracket notation can be used to return those facts without taxonomy defined dimensions. The square bracket and curly bracket notation is used independently.

Figure 11 below shows that the fact query body can be included in square, curly or no brackets.

Figure 11: Fact Query

A fact query with no brackets is the equivalent to curly brackets.

The square bracket notation can be used with no dimensions as follows:

    [@] or []

This will return all non taxonomy defined dimensions fact values in an instance.

When used with built in dimensions all facts with the built-in dimension are returned that have no taxonomy defined dimensions.

    [@concept = Assets]

This will only return fact values for Assets with no taxonomy defined dimensions.

Taxonomy defined dimensions can be defined in the expression such as the following:

    [@concept = Assets @LegalEntityAxis = *]

This will return all facts with using the Assets concept and the LegalEntityAxis. Facts with the LegalEntityAxis and another taxonomy defined dimension will not be returned.

To return facts with with the LegalEntityAxis and another taxonomy defined dimension the curly bracket notation is used, shown below.

    {@concept = Assets @LegalEntityAxis = *}

The @ character with no dimension name defined will return all facts. The @ can stand by itself as shown in the following examples. Curly brackets are optional.

{@}  or  {}  or  @ 

This will return all fact values in an instance

[@]  or  []  

This will return all fact values in an instance with no taxonomy defined dimensions.

6.10 Filter Control

6.10.1 Dimensional Alignment Control

All facts returned in a fact query have an associated dimensional alignment. Dimensional alignment is a dictionary with each dimension representing a key and each dimensional value representing a dictionary value. When performing operations on facts, the operations are performed between facts with the same dimensional alignment, this is called binding. All facts with the same dimensional alignment must bind. Each calculation defined will be performed for each dimensional alignment returned from the fact query. Each dimensional alignment will generate an iteration. Facts with no dimensional alignment dictionary will bind with facts in every iteration.

Literal values such as strings and integers defined in a rule have no dimensional alignment.

Dimensional alignment can only be associated with a fact.

Dimensional alignment may be removed from facts returned in a fact query using the covered keyword.

6.10.1.1 Covered Filters

Facts returned using a fact query may have the dimensional alignment removed by using the keyword covered in the fact query. The covered keyword will set the alignment to none. Facts with a dimensional alignment of none will bind with any other fact irrespective of their dimensional alignment. The keyword covered should be used before the dimension filters in the fact query expression.

The following example uses the covered keyword to remove all dimensional alignment from the facts returned by the query.

{covered @concept = Assets}

6.10.1.2 Using the At Sign (@) to Cover Specific Dimensions

The @@ syntax acts as a filter but also maintains the dimensional alignment of the fact. The @ syntax removes the dimension from the dimensional alignment of the fact.

Where multiple filters are used for the same dimension but have different alignment controls the processor will default to maintaining dimensional alignment and the double @ takes precedence.

The example below has different alignment control for the concept dimension:

@concept.balance = debit @@concept.period-type = instant

This resolves to:

@@concept.balance = debit @@concept.period-type = instant

If every dimension in the fact query is covered with an At Sign (@) this is not the same impact as covering the entire fact query using covered.

{@concept @entity @period @unit @dimensions}

The fact derived using @ on every dimension will only bind with other facts that have no dimensional alignment, but not with facts that have dimensional alignment.

type of cover alignment Impact
covered keyword No dimensional alignment Binds with all facts irrespective of dimensional alignment
dimensional alignment removed using @ empty dimensional alignment Binds with facts with no dimensional alignment or empty dimensional alignment

The double @@ forces dimensional alignment on a filter and can be used to uncover a specific dimension when it is covered using the keyword covered or covered-dims. It can also be used to cover a specific taxonomy defined dimension when the @dimension filter is used.

The following example shows using the double @@ to uncover a specific dimension filter.

list({covered @RevenueFromContractWithCustomerIncludingAssessedTax @@srt:ProductOrServiceAxis = *})

The expression will continue to align facts based on ProductOrServiceAxis and will create a separate iteration of the expression for each member on the ProductOrServiceAxis.

6.10.1.3 Using covered-dims to cover dimensions

Taxonomy defined dimensions can be covered using the keyword covered-dims.

The keyword covered-dims removes taxonomy defined dimension alignment from facts returned by a fact query. Facts that are covered with covered-dims maintain their core dimensional alignment. The keyword covered-dims should be used before the dimension filters in the fact query expression.

The following example uses the covered-dims keyword to remove taxonomy defined dimension from the dimensional alignment of the facts returned by the query.

    {covered-dims @concept = Assets}

6.11 Handling Nils

Facts can be defined in an instance with a nil value. Nils have no numeric value or decimal value.

The processor by default includes nil values in the fact query results. A processor can be instructed to exclude nil values from the fact query when processing is initiated. A fact query can be defined to exclude nil values by using the keyword nonils. The keyword nonils removes facts with a nil value from the fact query .

The keyword nils can be set to include nil values in the fact query. This is used if the processor is set to exclude nils A processor can be instructed to exclude nils from fact queries. The nils keyword will override the processor instructions.

A fact with a nil value will fallback to a value of zero for numeric facts if the nildefault keyword is used in the fact query.

The value returned for nil when the nildefault keyword is used differs depending on the type of the concept. If the concept is a numeric type then a value of zero is returned. If the concept is non numeric then an empty string is returned.

Any other type will return as nil.

6.12 Defining a Dimension Alias

A dimension filter can be referenced by defining an alias in the dimension filter. The alias name is defined as a local variable and is defined using the as keyword. The as keyword allows a dimension to be defined as an alias that can be used to reference a dimension filter in a where clause.

The alias name must be a simple name.

An alias makes it easier to handle expressions in the where clause as the names are shorter and easier to read.

The following expression uses an alias named '$lea' to represent a set of members on the legal entity axis.

{@concept = Assets @dei:LegalEntityAxis=* as $lea }

The alias can be used in the where clause as follows:

{@concept = Assets  @dei:LegalEntityAxis =* as $lea where $fact > 0 and $lea == ParentCompanyMember }

6.13 Where Clause

The where clause allows filtering of returned facts based on properties of the fact. The where clause can filter on all properties of the fact and has no impact on the dimensional alignment of the fact.

To evaluate fact query results with the where clause, use the $fact variable to refer to the attributes of the filtered fact.

The $fact variable is a built in alias representing the fact object returned from the fact query. All the properties of a fact object can be returned from $fact and operated on as part of the where clause.

The where clause must be contained within the fact query .

To return negative values from a filing, the $fact variable can be used as follows:

{@ where $fact < 0} 

The properties of $fact can also be evaluated.

{@unit ! = xbrli:pure where $fact < 0 and $fact.decimals == -6}

6.14 Nested Filters

Nested filters allow operations to be defined at different levels of dimensional alignment within an iteration.

Under normal processing all operators are performed within a single dimensional alignment. This alignment normally represents a single iteration. With nested filters operations with multiple dimensional alignment can be performed in a single iteration. This means results with one dimensional alignment can be compared to results with a different dimensional alignment in the same iteration.

Nested filters group fact queries within other fact queries. Dimensional alignment is performed at the lowest level. The results then roll up to the next level of the fact query.

For example, to calculate the net monthly payment for electricity service. The net monthly payment is expressed as follows:

{@actualMonthlyPayment} - {@actualMonthlyReimbursement}

This returns the net payment. All periods, units and dimensions align - i.e. the actual reimbursement for the month will be deducted from the actual payment for the same month and not for a different month.

The company has a contractual monthly rate with the electric utility, represented by the concept monthly payment. The monthly payment is a fixed amount with a period dimension value of forever. I.e. It is a monthly contract rate that is agreed for the term of the agreement. To determine the monthly difference between what they actually paid and what they were obligated to pay, the company deducts the actual payment and reimbursement from the contracted monthly rate. This could be incorrectly represented as follows:

{@contractedMonthlyPayment} - {@actualMonthlyPayment} - {@actualMonthlyReimbursement}

The contracted monthly payment has no period alignment and the actual payment and reimbursement are aligned with a monthly period. The facts required for the calculation are in different alignments. The calculation needs to be performed without regard to the period. To achieve this the period is taken out of alignment for the contracted monthly payment as shown below.

{@contractedMonthlyPayment @period} -  {@actualMonthlyPayment} - {@actualMonthlyReimbursement}

It's also necessary to take the actual payment and reimbursement out of period alignment so they can be compared with the contracted monthly payment. Furthermore, it's also necessary for the last two elements to be aligned by period with each other, so the monthly payment and reimbursement are subtracted using the same period. To accomplish this, the following relationship is grouped together in parenthesis as a new fact query.

{{@actualMonthlyPayment} - {@actualMonthlyReimbursement}}

This new group can now be compared to the contracted monthly payment when the period is taken out of alignment:

{@period {@actualMonthlyPayment} - {@actualMonthlyReimbursement}}

The full fact query is expressed as follows:

{@contractedMonthlyPayment @period}  - {@period {@actualMonthlyPayment} - {@actualMonthlyReimbursement}}

This query is represented in a hierarchical structure below.

If an instance has a contracted rate of $200 and paid the following amounts produces the following results:

Month Actual Monthly Payment Actual Monthly Reimbursement Netted Payment Contracted Amount $200 Difference
Jan 210 12 198 200 2
Feb 205 11 194 200 6
Mar 212 10 202 200 -2
Apr 210 6 204 200 -4

The $200 binds with every period even though there is only one value reported of $200. The value of $200 aligns with every period because the @period associated with the concept forces it to bind with all other values. The Netted Payment value for every period is taken out of period alignment to bind with the contracted amount of $200. The inner fact query remains in alignment with the period and the outer fact query is not in alignment with the @period.

6.15 Fallback values

If a fact query does not produce a result it will skip the iteration. If a fact query has a dependence on another fact query value in the expression that does return a result the empty fact query will fallback to a value of zero. The default fall back value of zero can be be changed using the first-value function (see Section 11.10.3). The first-value function allows a sequence of fallback values to be defined.

The following query expression returns the value of Assets minus the the value of Liabilities.

{@concept = Assets} - {@concept = Liabilities}

If the value of Liabilities does not exist it will fallback to zero.

The following expression will fall back to the value of LiabilitiesCurrent, and if that is not in the instance it will fallback to 100.

{@concept = Assets} - first-value({@concept = Liabilities},{@concept = LiabilitiesCurrent},100)

As many fallback values can be provided using the first-value function until a value is returned.

7 Taxonomy Navigation

Taxonomy Navigation is used to query relationships in a taxonomy.

The navigate query is used to instruct the processor to navigate the relationships in a taxonomy and return the relationship objects encountered as it follows each path as either a set, list or dictionary.

The navigate query has the following components:

The railroad diagram below describes how the navigate query components are sequenced and the permitted combinations.

Figure 12: Navigate query

The navigate function will navigate the trees until it reaches the end of the tree or encounters a concept it has already encountered. (A cycle)

If a cycle occurs the cycles attribute is flagged indicating the that navigation encountered a cycle. The processor will then stop navigation at that point. The relationship where the repeated concept is the target will be returned.

7.1 Selecting Arcroles to Navigate

Navigation can be limited to specified navigation arcroles. To define the arcrole to navigate either the full uri or the last path component of the arcrole uri can be used.

The following expression returns all descendent concepts using the parent-child arcrole.

navigate parent-child descendants

The two navigation's operations below are equivalent:

navigate parent-child descendants
navigate 'http://www.xbrl.org/2003/arcrole/parent-child' descendants

If the last path component of the uri is not unique within the taxonomy then all uri's with the same last path component are used as the arcrole parameter.

The arcrole navigation parameter can be a uri, a string, an arc-role object, a set or a list.

Multiple arcroles can be defined in a set or a list.

The arcrole parameter is optional in the navigate query.

7.2 Direction of Navigation

The navigation direction parameter indicates the direction taken when traversing arcroles defined in a taxonomy hierarchy.

Navigation direction must have one of the values described in Figure 13 below.

Figure 13: Navigation Direction

The descendants navigation direction instructs the processor to continue down all branches of the arcrole hierarchy from the starting concept until there are no more child concepts, or a stop condition is reached.

The children navigation direction instructs the processor to traverse down 1 navigation step of the arcrole hierarchy from the starting concept.

The ancestors navigation direction instructs the processor to continue up all branches of the arcrole hierarchy from the starting concept until the root concept is reached, or a stop condition is reached.

The parents navigation direction instructs the processor to traverse up 1 navigation step of the arcrole hierarchy from the starting concept.

The siblings navigation direction instructs the processor to select sibling relationships of the starting concept in the arcrole hierarchy. The sibling relationship returned is the relationship where the sibling is the target.

The previous-siblings navigation direction instructs the processor to select sibling relationships of the parent concept of the starting concept in the arcrole hierarchy.

The next-siblings navigation direction instructs the processor to select sibling relationships of the children concept of the starting concept in the arcrole hierarchy.

The source and target attributes of a relationship are not impacted by the navigation direction.

The number of relationships to navigate in a given direction are called navigation steps.

When the direction is defined as descendants or ancestors, the number of navigation steps can be specified after the navigation direction as an integer. If no navigation steps are defined then the navigation function continues down all branches until it reaches a leaf node.

The following navigate queries are equivalent

navigate parent-child descendants 1
navigate parent-child children

The navigation direction parameter must be defined when using a navigate query.

By default, navigation returns the target concepts of the relationships exclusive of the starting concepts.

7.3 Root Relationship

The include start keyword is used to return a synthetic relationship defining the root or starting concept as a relationship target concept.

To include root concepts, the include start keyword is defined after the navigation direction parameter.

The following will return parent-child relationships, including an artificial relationship defining the root as a relationship target concept.

navigate parent-child descendants include start

This following returns the root, child and grandchild concepts as target concepts.

navigate parent-child descendants 2  include start

When using ancestors and parents without a starting element the default start point is the root of the tree. This means the following expression will return no results

navigate ancestors

7.4 Start Point of Navigation

By default, navigation starts at the roots of an extended link role. The from concept instructs the navigate query to start navigation at a particular concept in a hierarchy. The keyword from preceding the concept object or concept QName indicates the starting concept. Concept properties cannot be used as a parameter of the from concept.

The following example will return all the child and grandchild relationship starting from Assets using the parent-child arcrole.

    navigate parent-child descendants 2 from Assets

7.5 End Point of Navigation

To define an end point of a navigation traversal a to concept is specified. The to concept instructs the navigate query to stop navigation at a particular concept in the hierarchy. The keyword to preceding the concept object or concept QName indicates the ending concept. Concept properties cannot be used as a parameter of the to concept.

If to concept is provided with the keyword 'to' then the relationships between the starting concept (or root concept) to the 'to concept will be returned.

The relationship where the target concept equals the to concept will be returned.

If a hierarchy is navigated and the 'to' concept is never reached then no relationships will be returned.

The example below shows an expression that ends when it encounters the target concept OtherAssetsCurrent

navigate parent-child descendants from Assets to OtherAssetsCurrent

This will return all the relationships that are descendants of Assets and will not return any relationships that are descendants of OtherAssetsCurrent. The results will only include those relationships that are in the path between Assets and OtherAssetsCurrent. Relationships in paths that do not end with OtherAssetsCurrent will not be included in the result.

7.6 Conditional Stopping of Navigation

The stop when keyword is used to stop navigation of a hierarchy when properties of the relationship equal a value defined in the navigate query. A navigation of a hierarchy is stopped when the keyword stop when is followed by a boolean expression that resolves to true.

The boolean expression evaluates if an attribute of the relationship matches a condition. This enables navigating a hierarchy and stopping navigation down a given branch when a condition is met on the relationship. The stop when keyword differs from the 'to' keyword in that all relationships that evaluate to false will be returned. Using the 'to' concept will only return relationships if the 'to' concept actually exists in the hierarchy.

The relationship that evaluates to true when using stop when will be returned as part of the result.

For example if a presentation tree is navigated and navigation stops when the target concept GrossProfit is reached, the relationship with the target concept of GrossProfit will be returned.

navigate parent-child descendants from IncomeStatementAbstract stop when $relationship.target.name == GrossProfit

The navigate query returns all the descendant relationships of IncomeStatementAbstract in the presentation linkbase of the filing, but excludes any descendants of GrossProfit.

7.7 Selecting Roles to Navigate

Relationships in a specific extended link role can be navigated by specifying the navigation role. The keyword role is followed by the role object, the role uri or the last component of the uri path. When the last path component of the role is used, the last path component must be unique within the taxonomy.

These two operations are equivalent:

navigate parent-child descendants role 'http://www.abc.com/role/ConsolidatedBalanceSheets'
navigate parent-child descendants role ConsolidatedBalanceSheets

The navigate query returns the presentation-child relationships used in the ConsolidatedBalanceSheets role.

The last path component of the role must not use quotes.

7.8 Selecting a Linkbase

To restrict navigation to a specific linkbase the linkbase navigation keyword is used. The linkbase keyword is followed by a linkbase link name. The link name must be defined as a QName. If a QName is not provided the xbrlqe:InvalidLinkbaseNavigationObject error is returned.

The example returns the descendant concepts of Assets concept in the calculation linkbase. This will return all calc descendants of Assets.

navigate descendants from Assets linkbase link:calculationLink taxonomy $US-GAAP-2020

7.9 Selecting Taxonomies to Navigate

By default, navigation occurs in the taxonomy of the instance document. The navigation taxonomy keyword is used to navigate a specific taxonomy other than the default taxonomy associated with the instance. The keyword taxonomy is used followed by the taxonomy object.

The expression below returns relationships from a taxonomy object defined using the taxonomy function.

navigate parent-child descendants from Assets taxonomy taxonomy('http://xbrl.fasb.org/us-gaap/2016/entire/us-gaap-entryPoint-std-2016-01-31.xsd')

If there are multiple instances documents, the taxonomy of the referenced instance can be identified by using the taxonomy property of the instance.

navigate parent-child descendants from Assets taxonomy $myInstance.taxonomy

This will return all the descendants of Assets in the referenced instance document.

7.10 Where Clause selection on Navigation Results

Navigation returns relationship information based on the relationship found during the traversal. A navigation where clause expression can be used to filter the relationships returned. For each relationship object, the where expression is evaluated.

If the 'where' expression for a relationship evaluates to true, the relationship is included in the result.

A special variable $relationship is used in the relationship where clause expression to refer to the properties of the relationship being filtered.

For example the relationship where clause can be used to exclude abstract concepts

navigate parent-child descendants from Assets where not $relationship.target.is-abstract

7.11 Returning Navigation Results

The default result of navigation returns a set of target concepts from the relationships matching the criteria of the navigation query.

The returns keyword is used to specify the return components of the relationship to return.

The following shows how the returns keyword is used to return the source concept of a relationship.

navigate parent-child descendants from AssetsAbstract returns (source)

Results are returned as a set of concepts.

set(AssetsAbstract,CurrentAssets,NoncurrentAssetsNoncurrent,Land,Cash,Assets)

The following return components may be specified:

The source keyword instructs the processor to return the relationship source concept of the relationship.

The source-name keyword instructs the processor to return QName of the source concept of the relationship.

The target keyword instructs the processor to return the target concept of the relationship.

The target-name keyword instructs the processor to return the QName of the target concept of the relationship.

The order keyword instructs the processor to return the relationship order property of the relationship.

The weight keyword instructs the processor to return the relationship weight property of the relationship.

The preferred-label keyword instructs the processor to return the label object for the label indicated by the preferred label for the target concept. This includes uri, description, lang and text properties.

The preferred-label-role keyword instructs the processor to return the role object for the preferred label. This includes the uri, description and used on properties. The relationship keyword instructs the processor to return the relationship object.

The role keyword instructs the processor to return the extended link role of the network where the relationship is defined.

The role-description keyword instructs the processor to return the description of the role of the network.

The arcrole keyword instructs the processor to return the relationship arcrole of the network the relationship is in.

The arcrole-description keyword instructs the processor to return the relationship arcrole-description property of the relationship.

The arcrole-cycles-allowed keyword instructs the processor to return the cycles allowed attribute of the arcrole definition. One of: 'any', 'undirected', 'none'.

The link-name keyword instructs the processor to return the QName of the extended link element.

The arc-name keyword instructs the processor to return the QName of the arc element.

The network keyword instructs the processor to return the relationship network property the relationship is in.

The cycle keyword instructs the processor to return the cycles attribute, a boolean indicator if the relationship starts a cycle in the navigation.

The navigation-order keyword instructs the processor to return the calculated sibling order of the relationship target. This is not the order on the relationship but is calculated during the navigation.

The navigation-depth keyword instructs the processor to return the depth of the relationship target concept from the starting concept.

The result-order keyword instructs the processor to return the order of the result within the full result list.

Defining a QName as an arc attribute instructs the processor to return the value of the arc attribute. The actual QName of the arc attribute is used in the returns statement.

For example:

returns (source-name, target-name, ex:specialAttribute)

ex:specialAttribute is the QName of the attribute on the arc.

The dimension-type keyword instructs the processor to return the purpose of the target concept in dimensional navigation. See Dimensional Navigation.

The dimension-sub-type keyword instructs the processor to return the more specific purpose of the target concept in dimensional navigation. See Dimensional Navigation.

The drs-role keyword instructs the processor to return the initial role of the dimensional relationship set. See Dimensional Navigation.

Multiple return components may be returned by composing them in parenthesis.

In the example below the navigate query will return a list of lists when executed. The inner list will be the values corresponding to the specified components.

navigate parent-child descendants from Assets returns (target, preferred-label)

The query will return a list of relationships. Each item in the list will be a list with two values, the target concept and the preferred label for the relationship.

The include start keyword creates an extra relationship result for each starting concept returned as the target. This affects the way the following return components are returned:

Return Component Return Component Value
source Returned as None
source-name Returned as None
target The start concept
target-name The QName of the start concept
order Returned as None
weight Returned as None
preferred-label Returned as None
relationship Returned as None
cycle False
navigation-order The calculated sibling order of the relationship target. This is not the order on the relationship but is calculated during the navigation.
navigation-depth 0
result-order The order of the result within the full result list
arc-attribute Returned as None
dimension-type The dimension type of the start concept
dimension-sub-type The dimension subtype of the start concept

7.11.1 Returning by Network

Unless otherwise specified the result of navigation is a flat list of items. The by network navigation keyword groups the relationships by the networks that they are located in. The by network keyword returns a dictionary where each network is the key and the value of associated with the key is a list of the specified return items.

The by network keyword is used to separate relationships by the extended link role. Figure 14 below graphically shows two extended link roles with relationships.

Figure 14: By Network

The following example shows how arc relationships are returned as a dictionary with the extended link role as a key.

    navigate parent-child descendants returns by network

This will return the following dictionary of lists of target concepts:

Key Value
role-one list(B, C)
role-two list(Y, Z)

7.11.2 Returns as Set or List

The return components from a navigate can be specified to indicate if they are returned as a set or a list. By default return components are returned as a list.

The returns-set keyword will return the values from evaluating the navigate function as a set rather than as a list.

The returns-list keyword will return the values from evaluating the navigate function as a list.

The following expression will return the target-name as a unique set of QName items rather than a list.

navigate summation-item descendants from  PropertyPlantAndEquipmentGross returns set (target-name)

7.11.3 Returning Paths

Default navigation returns a list of results. Alternatively, the results can be organized by the path of the navigation. The navigation paths keyword returns all of the relationships identified while traversing individual paths in a tree hierarchy. The path keyword results in path lists contained within an outer list. The outer list contains a list for each path of traversal. The inner list contains each relationship in the order of the traversal.

Figure 15 below graphically shows a hierarchy that has 4 paths if the starting node is 'A'.

Figure 15: Paths

The diagram has 4 paths that are defined in a list of lists when using the paths keyword.

The following example shows how arc relationships are returned as a list of lists.

    navigate parent-child descendants include start from A returns paths

This will return the following lists:

list(
    list(A,B,D),
    list(A,B,E),
    list(A,C,F),
    list(A,C,G)
    )

The following expression includes the start relationship using include start and returns the source, target, and order.

    navigate parent-child descendants include start from A returns paths (source, target, order)

This expression will return a list of lists in a list

list(
    list(
        list(None, A, None),
        list(A,B,1),
        list(B,D,1)
        )
    list(
        list(None, A, None),
        list(A,B,1),
        list(B,E,2))
    list(
        list(None, A, None)
        ,list(A,C,2)
        ,list(C,F,1)
        )
    list(
        list(None, A, None),
        list(A,C,2),
        list(C,G,2)
        )
    )

The following example demonstrates how paths can be used to calculate the effective weight between ProfitLoss and Revenues.

    product(navigate summation-item descendants include start from ProfitLoss to Revenues returns paths (weight))

7.12 Return as Dictionary

The default result value is a list. When multiple return components are returned, it can be more useful to have the result returned as a dictionary. The as dictionary keyword is used to structure returned results from a navigate function as key-value pairs where the keys are the names of the return components.

The example below shows how relationships are returned as a dictionary.

    navigate parent-child descendants from Assets returns (source, target, role) as dictionary

This will return a list of dictionaries. Each dictionary will have three entries with the keys of source, target and role.

Dictionary 1

Key

Value

source

Assets

target

AssetsCurrent

role

balanceSheet

Dictionary 2

Key

Value

source

Assets

target

AssetsNoncurrent

role

balanceSheet

Dictionary 3

Key

Value

source

Assets

target

AssetsOther

role

balanceSheet

Dictionary 4

Key

Value

source

AssetCurrent

target

Cash

role

balanceSheet

Dictionary 5

Key

Value

source

AssetsCurrent

target

CashEquivalents

role

balanceSheet

7.13 Dimensional Navigation

The dimensional relationship sets (DRS) comprise relationships from multiple arc roles and extended link roles to form a model of the cubes defined in the taxonomy.

Dimensional navigation is used to navigate the DRS. Figure 16 shows how the dimension arc roles are composed into the DRS

Figure 16: Dimensional Navigation

Dimensional navigation traverses the multiple arc roles that make up a DRS. For the purpose of dimensional navigation, the hypercube is the root of the structure. This differs from the standard XBRL dimension model which treats the primary item as the root of the structure. Note that the all arc role in the XBRL dimension model is from the primary item to the hypercube. In dimensional navigation, this is flipped and the all arc role is treated as from the hypercube to the primary item.

The dimensions keyword is used to indicate that the navigate expression should use dimensional navigation.

The following example will return all the dimension members of the Legal Entity Axis (dimension). If the dei:LegalEntityAxis dimension is used in multiple cubes with a different set of members, this will traverse the dimension in each cube.

navigate dimensions descendants from dei:LegalEntityAxis

Navigation is constrained to a single cube by using the cube keyword.

The cube keyword must only be used with dimensional navigation.

The following example will return all the dimension members of the Legal Entity Axis (dimension) in the us-gaap:StatementTable.

navigate dimensions descendants from dei:LegalEntityAxis cube us-gaap:StatementTable

Arc roles can be used to limit the results of dimensional navigation to only those relationships with the specified arc role.

The following example will return the domain concepts that are in the us-gaap:StatementTable.

navigate dimensions dimension-domain descendants from us-gaap:StatementTable

7.13.1 Pseudo Arcroles

In addition to the arc roles that are used to define dimensional relationships, these additional pseudo arc roles can be used.

The hypercube-primary arcrole will return relationships between a cube concept and the primary item concept. This arc is similar to the 'all' arc role to define a relationship between a primary item and a cube, but in the opposite direction.

The dimension-member arcrole will return domain-member relationships that stem from a dimension concept via a dimension-domain relationship. The arcrole only includes member concepts that are members of a dimension (not a primary item).

The primary-member arcrole will return domain-member relationships that stem from the primary concept of a cube. The arcrole only includes member concepts that are members of a primary item (not a dimension).

Any of the standard dimension arc roles, except for all and not-all, may be used for dimensional navigation. In dimensional navigation, the domain-member arc role applies to both members of a dimension and the members of the primary item.

When using an arcrole or pseudo arcrole the navigation will still traverse the DRS from the starting concepts regardless of the arc role specified. Only the relationships from the specified arcrole will be returned.

The example will return all the members of any dimension of the us-gaap:StatementTable. Note that the traversal starts from the hypercube concept on the hypercube-dimension relationship and then to the domain members via the dimension-domain relationships. Only the domain-member relationships are returned.

navigate dimensions dimension-member descendants from us-gaap:StatementTable

7.13.2 DRS Role

Dimensional navigation can traverse more than one extended link role. The original role used on the 'all' relationships between the primary item concept and the hypercube concept is the drs-role. This remains the same when navigating a DRS even though the extended link role may change.

To limit dimensional navigation to only one drs role the drs-role keyword can be used.

The example returns the dimension and the domain concepts that are in the us-gaap:StatementTable and the BalanceSheet extended link role.

navigate dimensions descendants from us-gaap:StatementTable drs-role BalanceSheet

The drs-role can be specified using the uri of the role in quotes or the last path component. When the last path component of the drs-role is used, the last path component must be unique within the taxonomy, otherwise the error xbrlqe:AmbiguousExtendedLinkRoleURI is returned.

7.13.3 Navigating Cubes

To restrict Dimensional navigation to a specific hypercube concept the cube navigation keyword is used. The cube keyword is followed by either a hypercube concept, QName or cube object. If any other object is provided the xbrlqe:InvalidCubeNavigationObject error is returned.

The cube keyword can only be used when using Dimensional navigation. If the navigation keyword dimensions is not provided the xbrlqe:CubeCanOnlyBeUsedInDimensionalNavigation error is returned.

The example returns the children concepts of the ScheduleOfFairValueOffBalanceSheetRisksTable. This will return the axis and line item concepts.

navigate dimensions children cube ScheduleOfFairValueOffBalanceSheetRisksTable taxonomy $US-GAAP-2020

7.13.4 Dimension Return Components

In addition to the non-dimensional navigation return components, dimensional navigation can use the following return components:

The dimension-type return component identifies the dimensional purpose of the target concept. The values are: * hypercube * primary-member * dimension * dimension-member

The dimension-sub-type return component identifies the specific dimensional purpose for dimensions and members. The values are:

  1. For dimension-type = dimension

  2. For dimension-type = dimension-member

  3. For dimension-type = primary-member

The drs-role return component identifies the network og the hypercube. The extended link role of the primary to hypercube relationship (all relationship). In a dimensional relationship set, the role can be different for different relationships. The drs-role is constant for relationships that make up the dimensional model of a cube.

The useable return component identifies the value of the usable attribute. If there is no usable attribute it defaults to true.

7.13.5 Navigating Across Networks

In some cases it is necessary to navigate between concepts irrespective of the extended link role they are contained within. The navigation across networks keyword returns relationships irrespective of the extended link role they are associated with. Using this keyword will return all relationship associated with a concept. If traversing multiple paths, the paths are combined across all extended link roles into one network.

Figure 17 shows two networks in different roles with the same arcrole.

Figure 17: Separate Networks

The across networks command will run the navigate as if the network is as follows:

Figure 18 shows a single network with the same arcrole.

Figure 18: Combined Networks

8 Processing Model

8.1 Iterations

The processing model is an iterative model. The query expressions defined are processed iteratively. The number of times a query runs is dependent on the number of facts selected using a fact query and/or iterations created by processing for loops defined in a query.

A query starts execution with a single iteration called a start iteration. Queries can add additional iterations using a for loop or by running a fact query which selects any number of facts. The number of iterations for a fact is dependent on the number of contexts.

Once a for loop starts the start iteration becomes the first iteration of the for loop.

The following query will generate 1 iteration, as it uses the start iteration.

output abc
'hello'

The following query will generate no iterations as the start iteration is superseded by the for loop.

output abc
for $x in list()
    'hello'

This query will generate 1 iteration.

output abc
for $x in list(1)
    'hello'

When using a fact query the start iteration becomes the iteration of the first fact.

If one fact for Assets is defined in an instance document, then the following query will generate 1 iteration. If there are 3 Asset facts the query will generate 3 iterations.

output abc
if exists({@concept = Assets})
    'hello'
else
    skip

If no facts for Assets are defined in an instance document, then the previous query will generate 0 iterations as the start iteration is superseded by fact iteration and no result is returned.

The existence of a fact must be evaluated within an iteration. Every fact based iteration is run within a dimensional alignment.

Dimensional alignment is defined by the dimensions that a fact exists in. Every fact must have dimensional alignment. When calculations are performed between facts, calculations will only be performed between facts that are in a common dimensional alignment. The number of iterations performed will mirror the number ofdimensional alignments of the facts selected.

The start iteration has no dimensional alignment. To test if a fact exists within an instance document, it must be evaluated in the start iteration. This means the fact has to be taken out of dimensional alignment.

The following query will return a results of 'Assets is absent'.

output abc
if exists({covered @concept = Assets})
    'Assets Exists'
else
    'Assets is absent'

The above query uses the covered keyword

The covered keyword removes the dimensional alignment from a fact. This allows the expression to be evaluated in the start iteration. If facts for assets do exist, the query will replace the start iteration with the fact iteration.

The query below shows where the start iteration is dropped and the iterations produced matches the iterations created by the number of facts.

output hello 

'hello ' + string([@Assets])

If there are three values for Assets then three iterations are created.

As each iteration completes an output is generated and the next iteration starts. Iterations can be collected in a set or list and output as a single output. However the fact alignment of the iterations has to be the same, (if not a for loop) as each list or set also has an associated dimensional alignment.

8.1.1 Skipping an Iteration

A skip keyword is used to skip an iteration generated by an aligned fact or by a for loop. When the processor encounters a skip keyword the current iteration is dropped. If within an iteration the skip key word is encountered the iteration will be dropped and the processor will move onto the next iteration.

A skip can be used to skip a loop in a for loop.

Iterations are also be skipped in the case of specific evaluations on none values. These are:

8.1.2 Aggregation of iterations

The results of iterations can be aggregated together by including the results of iterations in a collection such as a set or a list.

If the query below is run against an instance with 4 facts, 2 facts for Assets for 2018 and 2019 and 2 facts for Liabilities for 2018 and 2019, then 4 iterations are created, 1 for each fact. The following query aggregates the 4 iterations into two query results.

output agg
list(@concept in list(CurrentAssets,NoncurrentAssets))

The query above generates 2 results. The list is an aggregator of the fact query contained within it. Two lists will be returned containing 2 fact values. The first list will include the values for Assets and liabilities for 2018. The second list will include the values for Assets and liabilities for 2019.

Lists and sets can aggregate iterations together. Aggregation operators can also aggregate iterations.

8.2 Alignment

Operations are performed on facts in iterations. Operations will only be performed on facts with the same alignment. Given facts have a unique dimensional alignment within an XBRL instance, an expression must remove alignments between facts to perform operations on them. When fact queries define a dimension filter that dimension is removed from dimensional alignment.

The table below defines facts with 3 dimensions: Concept, Time and Subsidiaries. This matrix is comprised of 18 facts all with different dimensional qualifiers.

Concept Sub1 Sub2
2019 2020 2021 2019 2020 2021
CurrentAssets 123 169 234 322 444 611
NoncurrentAssets 387 533 734 1,012 1,394 1,921
Assets 510 702 968 1,334 1,838 2,523

A fact query selecting all of these facts will generate 18 iterations. For example:

output facts 

{ where $fact > 0}

This query will return all 18 results, or 1 result for each iteration.

By specifying a different query the iterations can be aligned and aggregated changing the number of results.

output facts 

$assets = {@concept = CurrentAssets} + {@concept = NoncurrentAssets}
$assets

The above query will create 6 results. The fact query select 12 facts. The + operator adds two iterations together thus producing 6 results from 12 iterations.

The instance document in this case is 3 X 3 X 2 matrix. Depending on the filters defined in the fact query this will change the available values and thus cut down the number of iterations.

The following query selects all the facts but selects all the dimensions.

output SumOfFacts 

$SumOfFacts = sum(list({@concept = * @period = * @SibAxis = *}))
$SumOfFacts

This will add all the values from the 18 iterations together and create a single result.

Whereas the following will create 3 results, 1 for each year.

output SumOfFacts 

$SumOfFacts = sum(list({@concept = *  @SibAxis = *}))
$SumOfFacts

Note that the removal of the period dimension will keep period data in alignment and will end in a sum for 2019, 2020 and 2021.

8.2.1 Alignment of Dimensions

Alignment represents the dimensions associated with a fact. This includes the non-taxonomy dimensions of concept, period, entity and unit as well as the taxonomy dimensions.

By specifying a dimension in a query it can be selected. The selection of the fact by a given dimension drops that alignment for the fact.

For example a fact of Assets has the following dimensions.

A query to select Assets

output AssetsAlignment 

{ @concept = Assets}

A query to select Assets defined above will result in the following alignment:

A query to select Assets in NZD

output AssetsAlignment 

{ @concept = Assets @unit=unit(iso4217:NZD)}

Will result in the following alignment:

A query to select Assets in NZD at 2085-12-31

output AssetsAlignment 

{ @concept = Assets @unit=unit(iso4217:NZD) @period = date('2085-12-31')}

Will result in the following alignment:

A query to select Assets in NZD at 2085-12-31 in Australia

output AssetsAlignment 

{ @concept = Assets @unit=unit(iso4217:NZD) @period = date('2085-12-31') @Geography = AU}

Will result in the following alignment:

To remove all the alignments on a fact the keyword covered can be used.

output AssetsAlignment 

{ covered @concept = Assets}

By adding dimensional qualifiers to a selection of facts will control the alignment of facts. Alignment has limited impact on an individual fact, but becomes important when aligning facts with different dimensions in a query.

8.2.2 Fact Properties Post Operation

The result of adding, subtracting or applying another operator to a fact will result in a value that has none of the properties of the originating facts. The resulting value will not have any built in dimensions, taxonomy defined dimensions or decimals. The resulting value will be a scaler value. The scaler value will still have alignment of the facts it was generated from, and will be able to participate in operations with other scalers or facts with the same alignment.

The query language cannot generate new facts from existing facts in the instance that are available to the processor as a fact object.

8.2.3 Scalers with no alignment

Scalers with no alignment such as an integer or decimal defined in an expression can participate in operations with values that do have alignment. A value with no alignment is distinct from a value with empty alignment. Empty alignment occurs when dimension filters remove all the dimensions in the dimensional alignment.

8.3 Processing nil and none Values

A nil value occurs when a fact in the XBRL instance has a value of nil. The fact query allows the binding of nil bindings to be defined.

A none value represents an empty result from evaluating an expression. A none value for a fact object is returned when a nil fact value is encountered in an instance document.

For example the following expressions will return a none value.

sum(set())

Summing a set or list that is empty will return a value of none.

dict(list(Assets, 'a qname'), list('a', 'a string'))['kitten']  

An index expression applied to a dictionary where the index is absent will return a value of none.

8.3.1 Nil Operations

When performing operations a none value defaults to the following when operated against the defined type.

Type Operator Value
integer, decimal, float +,- 0
string +,- ' '
set +,- set()

The table list how nil values must be processed with different operators.

Expression Operator Result
100 + none + 100
none + none + no iteration
none + 'hello' + 'hello'
set(1,2,3) + none + set(1,2,3)
none + skip + no iteration
skip + none + no iteration
100 - none - 100
none - 100 - -100
none - none - no iteration
none - 'hello' - 'hello'
'hello' - none - 'hello'
set(1,2,3) - none - set(1,2,3)
none - skip - no iteration
skip - none - no iteration
100 +> none +> no iteration
none +> 100 +> 100
3 / none / no iteration
none / 3 / no iteration
3 * none * no iteration
none > 0 > none
none == 1 == false
none == none == true
none > none > none
none >= none >= true
none <= none <= true
none and TRUE and no iteration
none and FALSE and FALSE
none and none and no iteration
none or TRUE or TRUE
none or FALSE or no iteration
none or none or no iteration

The table lists how nil values must be processed with different functions

function result
exists(none) true
missing(none) false
first-value(none) skip
first-value-or-none(none) none

Properties of a none value will return a value of none. The property is-fact (see Section 11.8.2) will return a value of false.

When an If-else statement has a condition that resolves to none then the expression resolves to an unbound condition and the iteration is skipped.

See functions section for how each function handles none values.

8.4 Object Model

The processing model is based on the object model. The processing model operates on the object model independently of the syntax of the instance or taxonomy documents.

9 Collections

A collection is used to refer to sets, lists and dictionaries. XBRL query supports sets, lists and dictionaries and operations between them.

9.1 Sets

A set is an unordered collection that cannot include duplicates. Sets can be used to remove duplicates and to test for membership in a set. Sets allow the use of mathematical operations like union, intersection, difference, and symmetric difference. Sets cannot be sorted.

Any duplicate values assigned to a set are removed. If a covered fact query is used to derive a set, any facts with the same value are removed from the set, even if other attributes of the fact are different. Facts in a collection should generally use a list as an aggregator and not a set. A set is defined using the set() function.

9.1.1 Set Specific Operations

9.1.1.1 union(set to union) : set

The union operation will produce a union of two sets, eliminating any duplicate items contained in either set.

The union of two sets can also be performed using the + operator.

A union performed using the + operator must only be performed between two sets. A union performed using the + operator between two incompatible collections results in a xbrlqe:IncompatibleOperator error.

A union performed using the union property can use a list as an argument. The processor will cast the list in the argument to a set. The union property must only be used as a property of a set. xbrlqe:InvalidObjectProperty

The following examples show using the union property and union operator.

Using a union operator

$A = set(a,b,c);
$B = set(c,d,e);
$A + $B

Using a union property

$A = set(a,b,c);
$B = set(c,d,e);
$A.union($B)

In both cases the result will be

set(a,b,c,d,e)

When the union is used as a property of none a value of none will be returned.

none.union(set(1,2,3))

This returns a value of none as all properties of a none object are returned as a none value.

When the + operator is used to union none with a set the value of the set will be returned. The + operator has special handling for missing data. If one side of the + operator is none then the value of the set is returned.

none + set(1,2,3)

This returns a value of set(1,2,3)

9.1.1.2 intersect(set to intersect) : set

The intersect operation will produce an intersection of two sets, eliminating any duplicate items contained in either set.

The intersection of two sets can also be performed using the & or intersect operator.

A intersection performed using the & or intersect operator must only be performed between two sets. An intersection performed using the & or intersect operator between two incompatible collections results in a xbrlqe:IncompatibleOperator error.

An intersection performed using the intersect property will cast the list in the argument to a set. The intersect property must only be used as a property of a set. xbrlqe:InvalidObjectProperty

The following examples show using the intersect property and intersect operators.

Using a & operator

$A = set(a,b,c);
$B = set(c,d,e);
$A & $B

Using an `intersect`` operator

$A = set(a,b,c);
$B = set(c,d,e);
$A intersect $B

Using an intersect property

$A = set(a,b,c);
$B = set(c,d,e);
$A.intersect($B)

In all cases the result will be

set(c)

When the intersect is used as a property of none a value of none will be returned.

The following example shows handling of an intersect property on a value of none.

$A = set(a,b,c);
none.intersect($A)

Results in the following:

none

This returns a value of none as all properties of a none object are returned as a none value.

If the & or intersect operator is used with a value of none, the processor will return an error. xbrlqe:IncompatibleOperator

The following example will produce an error.

$A = set(a,b,c);
none & ($A)

9.1.1.3 difference(set to deduct) : set

The difference operation will produce the difference between two sets. The elements in the second set are deducted from the first set.

The difference of two sets can also be performed using the - operator.

A difference performed using the - operator must only be performed between two sets. A difference performed using the - operator between two incompatible collections results in a xbrlqe:IncompatibleOperator error.

A difference performed using the difference property will cast the list in the argument to a set. The difference property must only be used as a property of a set or a dictionary. xbrlqe:InvalidObjectProperty

The following examples show using the difference property and difference operator.

Using a - operator

$A = set(a,b,c);
$B = set(c,d,e);
$A - $B

Using a difference property

$A = set(a,b,c);
$B = set(c,d,e);
$A.difference($B)

In all cases the result will be

set(a,b)

When the difference is used as a property of none a value of none will be returned.

The following example shows handling of a difference property on a value of none.

$A = set(a,b,c);
none.difference($A)

Results in the following:

none

This returns a value of none as all properties of a none object are returned as a none value.

When the - operator is used to difference none with a set the value of the set will be returned. The - operator has special handling for missing data. If one side of the - operator is none then the value of the set is returned.

none - set(1,2,3)

This returns a value of set(1,2,3)

9.1.1.4 symmetric-difference(sets to diff) : set

The symmetric-difference operation will produce a set of elements which are in either of the sets, but not in their intersection

The symmetric-difference of two sets can also be performed using the ^ operator.

A symmetric-difference performed using the ^ operator must only be performed between two sets. A symmetric-difference performed using the ^ operator between two incompatible collections results in a xbrlqe:IncompatibleOperator error.

The following examples show using the symmetric-difference property and symmetric-difference operator.

Using a ^ operator

$A = set(a,b,c);
$B = set(c,d,e);
$A ^ $B

Using an symmetric-difference property

$A = set(a,b,c);
$B = set(c,d,e);
$A.symmetric-difference($B)

In all cases the result will be

set(a,b,d,e)

When symmetric-difference is used as a property of none a value of none will be returned.

The following example shows handling of an symmetric-difference property on a value of none.

$A = set(a,b,c);
none.symmetric-difference($A)

Results in the following:

none

This returns a value of none as all properties of a none object are returned as a none value.

If the ^ operator is used with a value of none, the processor will return an error. xbrlqe:IncompatibleOperator

The following example will produce an error.

$A = set(a,b,c);
none ^ ($A)

9.1.1.5 is-subset(set to test) : boolean

The is-subset operation will produce a boolean result if one set is a subset of another set.

The is-subset of two sets can also be performed using the <= operator.

A is-subset performed using the <= operator must only be performed between two sets. A <= operator between two incompatible collections results in a xbrlqe:IncompatibleOperator error.

The following examples show using the is-subset property and is-subset operator.

Using a ^ operator

$A = set(a,b,c);
$B = set(a,b,c,d,e);
$A.is-subset($B)

Using a is-subset property

$A = set(a,b,c);
$B = set(a,b,c,d,e);
$A <= ($B)

In all cases the result will be

true

When is-subset is used as a property of none a value of none will be returned.

The following example shows handling of an is-subset property on a value of none.

$A = set(a,b,c);
none.is-subset($A)

Results in the following:

none

This returns a value of none as all properties of a none object are returned as a none value.

If the <= operator is used with a value of none, the processor will return none.

The following example will produce a none.

$A = set(a,b,c);
none <= ($A)

9.1.1.6 is-superset(set to test) : boolean

The is-superset operation will produce a boolean result if one set is a superset of another set.

The is-superset of two sets can also be performed using the >= operator.

A is-superset performed using the >= operator must only be performed between two sets. A >= operator between two incompatible collections results in a xbrlqe:IncompatibleOperator error.

The following examples show using the is-superset property and is-superset operator.

Using a ^ operator

$A = set(a,b,c);
$B = set(a,b,c,d,e);
$B.is-superset($A)

Using an is-superset property

$A = set(a,b,c);
$B = set(a,b,c,d,e);
$B >= ($A)

In all cases the result will be

true

When is-superset is used as a property of none a value of none will be returned.

The following example shows handling of an is-superset property on a value of none.

$A = set(a,b,c);
none.is-superset($A)

Results in the following:

none

This returns a value of none as all properties of a none object are returned as a none value.

If the >= operator is used with a value of none, the processor will return none.

The following example will produce a none.

$A = set(a,b,c);
none >= ($A)

9.1.2 Set Properties

Sets have the following properties:

9.2 Lists

A list is an ordered collection that can include duplicates. Lists can be sorted. A list is defined using the list() function.

9.2.1 List Properties

9.2.2 Set and List Operators

Operation
Operator Property Sets Syntax Result
Test if item is in set or list in $A = set(a,b,c); c in $A TRUE
Test if set or list contains item contains() $A = set(a,b,c); $A.contains(c) TRUE
Test if item not in set or list not in $A = set(a,b,c); b not in$ A FALSE

9.3 Dictionaries

A dictionary is an unordered set of key: value pairs, with the requirement that the keys are unique (within one dictionary). A dictionary can be defined using the dict() function.

The following example defines a dictionary with axis keys and member values.

dict(list('AAxis','AMember'),list('BAxis','BMember'))

This uses the comma to separate the key from the value. Alternatively a dictionary can be created by converting a set or list of lists to a dictionary. This is done using the to-dict function.

set(list('AAxis','AMember'), list('BAxis','BMember')).to-dict

A dictionary cannot be created using curly brackets.

9.3.1 Dictionary Specific Operations

9.3.1.1 Dictionary Index

To retrieve a value from a dictionary based on a key the square bracket operator [] is used.

The following examples show using the index operator is used.

Using a union operator

$A = dict(list('AAxis','AMember'), list('BAxis','BMember'));
$A['AAxis']

This will return

'AMember'

The index operator of a dictionary will return none if the key value does not exist in the dictionary.

9.3.1.2 In Dictionary Operator

The in operator can be used to test if a key is in a dictionary. The equivalent property is has-key (see Section 11.14.2).

The following examples show using the in operator.

$A = dict(list('AAxis','AMember'), list('BAxis','BMember'));
$B = 'AAxis'
$B in $A

In result will be

true

9.3.1.3 union(dictionary to union) : dictionary

The union operation will produce a union of two dictionaries, eliminating any duplicate keys contained in either dictionary. If the same key is added, then the add is not performed for the matching key.

The union of two dictionaries can also be performed using the + operator.

A union performed using the + operator must only be performed between two dictionaries. A union performed using the + operator between two incompatible collections results in a xbrlqe:IncompatibleOperator error.

The following examples show using the union property and union operator.

Using a union operator

$A = dict(list('AAxis','AMember'), list('BAxis','BMember'));
$B = dict(list('YAxis','YMember'));
$A + $B

Using a union property

$A = dict(list('AAxis','AMember'), list('BAxis','BMember'));
$B = dict(list('YAxis','YMember'));
$A.union($B)

In both cases the result will be

dict(list('AAxis','AMember'), list('BAxis','BMember'), list('YAxis','YMember'));

When the union is used as a property of none a value of none will be returned.

none.union(dict(list('AAxis','AMember'), list('BAxis','BMember')))

This returns a value of none as all properties of a none object are returned as a none value.

When the + operator is used to union none with a dictionary the value of the dictionary will be returned. The + operator has special handling for missing data. If one side of the + operator is none then the value of the dictionary is returned.

none + dict(list('YAxis','YMember'))

This returns a value of

dict(list('YAxis','YMember'))

9.3.1.4 difference(dictionary to deduct) : dictionary

The difference operation will produce the difference between two dictionaries. The dictionary pairs in the second dictionary are deducted from the first dictionary. The keys and values must match. If not then the left dictionary is maintained.

The difference of two dictionaries can also be performed using the - operator.

A difference performed using the - operator must only be performed between two dictionaries or a dictionary and list (see Section 9.3.1.5). A difference performed using the - operator between two incompatible collections results in a xbrlqe:IncompatibleOperator error.

The difference property must only be used as a property of a set or a dictionary. xbrlqe:InvalidObjectProperty

The following examples show using the difference property and difference operator.

Using a - operator

$A = dict(list('AAxis','AMember'), list('BAxis','BMember'));
$B = dict(list('BAxis','BMember'));
$A - $B

Using a difference property

$A = dict(list('AAxis','AMember'), list('BAxis','BMember'));
$B = dict(list('BAxis','BMember'));
$A.difference($B)

In all cases the result will be

dict(list('AAxis','AMember'))

When the difference is used as a property of none a value of none will be returned.

The following example shows handling of a difference property on a value of none.

$A = dict(list('AAxis','AMember'), list('BAxis','BMember'));
none.difference($A)

Results in the following:

none

This returns a value of none as all properties of a none object are returned as a none value.

When the - operator is used to difference none with a dictionary the value of the dictionary will be returned. The - operator has special handling for missing data. If one side of the - operator is none then the value of the dictionary is returned.

none - dict(list('AAxis','AMember'), list('BAxis','BMember'))

This returns a value of dict(list('AAxis','AMember'), list('BAxis','BMember'));

9.3.1.5 Subtract List of Keys Operator

The subtract dictionary key operator removes a key(s) and associated value from a dictionary. If keys don't match the left dictionary is maintained.

The removal or keys is performed using the - operator. On the left side is the dictionary to remove keys from and on the right side of the - operator is a list of keys to remove.

The following example shows using the remove key operator.

$A = dict(list('AAxis','AMember'), list('BAxis','BMember'));
$B = list('BAxis');
$A - $B

The result will be

dict(list('AAxis','AMember'))

9.3.2 Dictionary Properties

10 Operators

Operators are used between variables, collections and values.

10.1 Comparison Operators

Comparison operators compare two values for equivalence. The result is a boolean value.

Operator Description
< Less than
> greater than
>= Greater than or equal
<= Less than or equal
== Equivalent to. Can be used on a set or a list
!= Not equivalent to. Can be used on a set or list
in In evaluates if an object is contained in a set, list, string or uri.

10.2 Boolean Operators

Operator Description
and Logical AND. The AND operator is lazy
or Logical OR. The OR operator is lazy
not Changes a boolean from false to true or from true to false

10.3 Numeric Operators

Operator Description
+ Addition of numbers, strings, lists and sets.
- Subtraction, unary
* Multiplication
/ Division
<+> Addition that will occur if both left and right side are present
<+ Addition will only occur if left side is present.
+> Addition will only occur if right side is present.
<-> Subtraction that will only occur if both values are present on either side of the subtraction.
<- Subtraction will only occur if left side is present.
-> Subtraction will only occur if right side is present.
power() This is a property and not the operator ^ as this is used for symmetric difference in collection operators.

A division by zero will produce a divide by zero error xbrlqe:DivByZero.

10.4 Using Comparison Operators with Time

Operator Description
> Test if a time duration is after another time duration. Returns false if there is an overlap.
├──┤ ┣┫
If the end and start date meet this is considered after.
├──╊┫
< Test if a time duration is before another time duration. Returns false if there is an overlap.
== Test if two durations are the same duration. The start and end times must match.
!= Test if two durations are not the same duration.

10.5 Order of Operator Precedence

Order Operator Description
1 () Parenthesis
2 # Tagging
3 [ ] Index
4 . Property expression
5 +, - Unary, union
6 * , / Multiplication and Division
7 +, - Addition and subtraction
8 &, intersect Set intersections
9 ^ Symmetric Difference
10 >,<,>=,<=,in,not in, == , != Comparison Operators
11 NOT Boolean not
11 AND Boolean and
11 OR Boolean or

11 Properties and Functions

All object properties can be defined as functions.

Properties are referenced by using a dot notation after an object.

Sets or lists of an object can be used with a property. The property is applied to each item in the collection and returns the properties of each item as a set or a list. The type of the items in the collection must be appropriate to the property being applied. Sets or lists cannot be used as a parameter in a function to evaluate the properties of the set or list.

The following set contains role object values. The property will return the uri of each role.

set($role1, $role2, $role3).uri

the result will be a set or uri's.

set('http:uri.com/role1', 'http:uri.com/role2', 'http:uri.com/role3')

This expression below is invalid and produces error xbrlqe:FunctionNotProperty.

uri(set($role1, $role2, $role3))

11.1 Property and Function Errors

Error Message Property Error Description
xbrlqe:InvalidObjectProperty Invalid property of the object
xbrlqe:InvalidPropertyParameterType Invalid parameter type
xbrlqe:InvalidPropertyParameterValue Invalid parameter value
xbrlqe:InvalidNumberOfParameters Invalid number of parameters
xbrlqe:FunctionNotProperty Function cannot be used as a property
xbrlqe:FunctionNotFound The function is not found

11.2 Taxonomy Functions

The following taxonomy functions are properties of a taxonomy that take parameters in addition to the taxonomy object. The taxonomy properties that do not take parameters are defined in the object model. (see Section 3.1.1.1)

11.2.1 concept(concept QName) : concept object

Name Definition
Definition Returns the concept in a taxonomy based on the concept QName.
Object taxonomy
Parameters concept QName : QName of the concept
Example taxonomy().concept(Assets))
Returns the Assets concept from the taxonomy.

11.2.2 cube(statement table concept|QName, drs-role) : cube object

Name Definition
Definition Returns a cube object from a taxonomy object based on the table QName and the drs-role. The first argument can be the concept or QName of the cube. The role is the drs-role. The drs-role can be the last component of the uri, the uri or the role.
Object taxonomy
Parameters concept QName : QName or concept of the table
drs-role : The drs-role of the hypercube. This can be the role object, uri, or unique suffix of the uri.
Example taxonomy().cube(StatementTable, ShareholdersEquity)
Returns the cube used for shareholders .

11.2.3 effective-weight(concept1, concept2) : integer

Name Definition
Definition The effective weight between two concepts aggregated across all calculation networks comprising the taxonomy object. If the weight is not the same across networks it returns 0. The values can be -1, 1 or 0.
Object taxonomy
Parameters concept1 : concept or concept QName
concept2 : concept or concept QName
Example $us-gaap.effective-weight(Assets, AccumulatedDepreciation)
Returns the calculation weight of -1

11.2.4 effective-weight-network(concept1, concept2, role uri) : set

Name Definition
Definition The effective weight between two concepts in a given calculation network in the taxonomy object. Returns a set of lists containing the effective weight between the 2 concepts and the network object. The third parameter (role uri) is optional. If the network is not provided the operator returns the effective weight between the QNames for each network. The values can be -1, 1 or 0.
Object taxonomy
Parameters concept1 : concept or concept QName
concept2 : concept or concept QName
role uri : string - Network to use for effective calculation weight.
Example $us-gaap.effective-weight(Assets, AccumulatedDepreciation, 'https://xbrl.fasb.org/balanceSheet')
Returns set(list(-1,'https://xbrl.fasb.org/balanceSheet')

11.2.5 element(custom name) : element

Name Definition
Definition Returns the element in a taxonomy based on the element QName.
Object taxonomy
Parameters custom name : element QName
Example taxonomy().element(CustomElement)
Return the CustomElement from the taxonomy of the instance.

11.2.6 networks(arcrole, extended link role) : network object

Name Definition
Definition Returns a set of network objects from the taxonomy. Allows the parameters of arc role and extended link role. Both of the parameters are optional. The extended link role can use a short name but should not be in quotes.
Object taxonomy
Parameters arcrole : arc-role uri or uri suffix.
extended link role : uri or short uri
Example taxonomy().networks()
Returns all networks in the taxonomy
taxonomy().networks(parent-child)
Returns all the parent-child networks in the taxonomy.
taxonomy().networks(parent-child,'http://www.abc.com/role/ConsolidatedBalanceSheets')
Returns the parent-child network for the consolidated Balance Sheet in the taxonomy.
taxonomy().networks(parent-child,ConsolidatedBalanceSheets)
Returns the parent-child network for the consolidated Balance Sheet in the taxonomy. This uses the short name (No quotes).

11.3 Concept Functions

The following concept functions are properties of a concept that take parameters in addition to the concept object. The concept properties that do not take parameters are defined in the object model. (see Section 3.1.2.1)

11.3.1 all-labels(label role, language): set

Name Definition
Definition The all-labels function returns a set of labels for the concept. Label role and language will filter the result to only return labels that match the label role and/or language specified. To return all labels for a given language, use none for the label role.
Object concept, role
Parameters label role : uri - role uri
language : string - use ISO language code
Example taxonomy().concept(Assets).all-labels
Returns a set of all the labels associated with the Assets concept.
taxonomy().concept(Assets).all-labels(none,'en')
Returns all the labels associated with the Assets concept in english.

11.3.2 attribute(attribute name) : string

Name Definition
Definition Returns the value of a custom attribute based on the name provided to the function.
Object concept
Parameters attribute name : string - custom attribute of the concept
Example $fact.concept.attribute(abc)
Returns the value of abc

11.3.3 is-type(data type) : boolean

Name Definition
Definition Returns a boolean result if the concept has the type passed in the parameter. The type is provided as a QName.
Object concept, fact
Parameters data type : QName - data type QName to compare to concept data type.
Example $fact.concept.is-type(xbrli:monetaryItemType)
Returns the value of true if the fact is for Assets

11.3.4 label(label role, language): label

Name Definition
Definition The label function can be used to return one label associated with a concept. The two parameters are optional. If no parameters are provided and multiple label objects exist, then the processor will return the label object with the standard label. The label object with the documentation label will only be returned if no other label object is defined.
Object concept, role
Parameters label role : uri - role uri
language : string - use ISO language code
Example taxonomy().concept(Assets).label.text
Returns the text of the first label found for Assets.

11.3.5 references(reference role): set

Name Definition
Definition The references function can be used to return a set of references associated with a concept for a given dts. If no role is provided it defaults to the first role that has a reference. The roles checked are based on an ordered list.
Object concept, role
Parameters reference role : uri - role uri
Example taxonomy().concept(Assets).references("http://www.xbrl.org/2003/role/presentationRef")
Returns a set of reference objects for Assets based on the role provided or the default role.

11.3.6 part-by-name(part QName): qname

Name Definition
Definition Returns the reference part for a reference based on part name.
Object reference
Parameters part QName : QName of the part
Example reference.part-by-name(cod:Topic).part-value
Returns the reference part value for the qname cod:Topic.

11.4 Fact Functions

The following fact functions are properties of a fact that take parameters in addition to the fact object. The fact properties that do not take parameters are defined in the object model. (see Section 3.2.2.1)

11.4.1 dimension(dimension qname): qname

Name Definition
Definition Returns the member of the fact for the specified dimension
Object fact
Parameters dimension qname : Qname of the dimension associated with the fact.
Example {@ where $fact.dimension(dei:LegalEntityAxis).name == ABC}
Matches facts where the legal entity axis has a member of ABC.

11.5 Numerical Properties and Functions

11.5.1 abs() : decimal | float | integer

Name Definition
Definition Returns the absolute value of a numerical value. Can be used on an integer, float, decimal and fact type. None type returns an error.
Object integer, float, decimal or fact
Example {@Assets}.abs
abs({@Assets})
Returns the value of assets as an absolute value.

11.5.2 decimal() : decimal

Name Definition
Definition Returns the value as a decimal.
Object integer, float, decimal, string, fact
Example decimal(10)
10.decimal
Returns the value of 10.

11.5.3 int() : integer

Name Definition
Definition Returns the value as an integer. The int function always rounds down to the integer. Int removes any decimal places. Infinity cannot be converted to an integer xbrlqe:CannotConvertInfinityToInteger
Object integer, float, decimal or fact
Example int(10.98)
10.98.int
Returns the value of 10.

11.5.4 log10() : float

Name Definition
Definition Returns the log of a number. Can be used on an integer, float, decimal or fact type. A negative value returns none. The log10 of inf returns inf.
Object integer, float, decimal or fact
Example {@Assets}.log10
log10({@Assets})
Returns the log10 value of assets.

11.5.5 power(exponent) : float

Name Definition
Definition Returns the power of a number. Can be used on an integer, float, and decimal type.
Object integer, float, decimal, or fact.
Parameters exponent : integer, decimal, fact
Example 4.power(2)
Returns the square of 4 or 16.

11.5.6 signum() : integer

Name Definition
Definition Returns a value of -1 if the number is negative and a value of positive 1 if positive. If the value is zero it returns 0. Can be used on an integer, float, decimal and fact type
Object integer, float, decimal or fact
Example {@Assets}.signum
signum({@Assets})
Returns a value of -1 if assets is negative.

11.5.7 trunc(decimal places) : integer | decimal

Name Definition
Definition Truncates the number provided to the number of decimal places defined in the parameter. Decimal places defaults to zero if not provided.
Object integer, float, decimal or fact
Parameters decimal places : integer (optional)
Example {@Assets}.trunc(2)
trunc({@Assets},2)
truncates the value of assets to two decimal places

11.5.8 round(decimal places) : integer | decimal

Name Definition
Definition Rounds a number to the decimal places indicated. Rounds to the nearest even.
Object integer, float, decimal or fact
Parameters decimal places : integer
Example {@Assets}.round(2)
round({@Assets},2)
Rounds the value of assets to two decimal places

11.5.9 mod(divisor) : integer | decimal

Name Definition
Definition Rounds a number to the decimal places indicated. Rounds to the nearest even.Decimal places defaults to zero if not provided.
Object integer, float, decimal or fact. The object is the numerator
Parameters divisor : integer, decimal, float or fact
Example {@Assets}.mod({@Liabilities})
mod({@Assets},{@Liabilities})
Returns the mod of Assets divided by Liabilities

11.5.10 random(decimal places) : decimal

Name Definition
Definition Returns a random number between 0 and 1. Places defaults to 4 if not provided. Random cannot be used as a property.
Object No object
Parameters decimal places : integer (optional)
Example random()
Returns random number between 0 and 1.

11.6 Cube Properties and Functions

11.6.1 dimension(dimension QName) : dimension object

Name Definition
Definition Returns the dimension object from a specific cube by providing a dimension QName.
Object cube
Parameters dimension QName : QName or concept of the dimension.
Example $CUBE.dimension(us-gaap:CountryAxis)
Returns the dimension object on the $CUBE object with the axis QName of us-gaap:CountryAxis.

11.7 String Properties and Functions

11.7.1 clark(concept) : string

Name Definition
Definition Returns a string in clark notation when provided a QName, concept, part-element, fact, reference-part.
Object QName, concept, part-element, fact, reference-part
Example $US-GAAP-2020.concept(Assets).clark
Returns a string of {http://fasb.org/us-gaap/2020-01-31}Assets

11.7.2 contains(search item) : boolean

Name Definition
Definition Contains returns a boolean result if the provided value is contained in the provided search item. If the search item is an empty string then false is returned. If none is supplied it returns false.
Object string, uri
Parameters Search item : string or none
Example 'http://some/role/for/cashflow/'.contains('cashflow')
Returns a boolean of true

11.7.3 index-of(search string) : integer

Name Definition
Definition The index-of returns an integer of the position of the first instance of a given string in another string. If the string is not found a value of 0 is returned. If the search string is an empty string the function returns 0. If the search string is none the function returns 0. The string starts at 1.
Object string, uri
Parameters Search string : string or none
Example 'Hello Mr. Stains'.index-of('llo')
Returns a value of 3

11.7.4 inline-transform(transform name, datatype) : any

Name Definition
Definition The inline-transform property transforms a string value to a valid defined data type using a transform defined in the inline transformation registry. The first parameter is the string to be transformed, the second parameter is the QName of the transform and the third optional parameter is the datatype. If the third parameter is not provided it will default to a string. If a transform is performed on a none it returns none.
Object string, uri, none
Parameters transform name : QName - QName representing the transform in the transform registry.
datatype : string (optional) - datatype resulting from the transform. This can be decimal, date, integer
Example '1,234,567.89'.inline-transform(ix4:num-dot-decimal)
Returns a string value of 1234567.89
'1,234,567.89'.inline-transform(ix4:num-dot-decimal, 'decimal')
Returns a decimal value of 1234567.89
inline-transform('1,234,567.89', ix4:num-dot-decimal, 'decimal')
Returns a decimal value of 1234567.89

11.7.5 last-index-of(search item) : integer

Name Definition
Definition The last-index-of property returns an integer of the position of the last instance of a given string in another string. If the string is not found a value of 0 is returned. If the search string is an empty string the function returns 0. If the search string is none the function returns 0. The string starts at 1.
Object string, uri
Parameters Search string : string or none
Example 'Hello Mr Stains'.last-index-of('o')
Returns a value of 5

11.7.6 length() : integer

Name Definition
Definition The length property returns an integer of the number of characters in a string. When applied to a set or a list it returns the number of items in a collection. When applied to a dictionary it returns the number of key value pairs.
Object string, uri, set, list, dictionary
Example 'Hello Mr. Stains'.length()
Returns a value of 16
set(1,2,3,4,5,6).length
Returns an integer of 6

11.7.7 lower-case() : string

Name Definition
Definition Returns a string as lowercase characters.
Object string, uri
Example 'HTTP://some/role/for/cashflow/'.lower-case()
Returns the string as a lowercase string

11.7.8 number() : decimal | float | integer

Name Definition
Definition Converts a string to a number. If the string has a period it is converted to a decimal. If it has inf then it is converted to a floating number otherwise the string is converted to an integer.
Object string, uri
Example '3.4'.number
Returns a decimal number value of 3.4

11.7.9 regex-match(regex match pattern) : dictionary

Name Definition
Definition Returns a dictionary of information about the regular expression match. The dictionary contains the following keys:
end: The character position in the string where the match ended.
groups: Returns the groups used in the regular expression. Groups are defined using parenthesis in the pattern.
match: The text of the string that matched the regular expression pattern.
Match-count: The number of matches.
start: The character position in the string where the match started.
If there is no match, the match value is none and the match-count is zero.
Uses python regular expression variant.
Object string, uri
Parameters regex match pattern : string
Example 'abcdefg'.regex-match('de+')
Returns a dictionary of: dict('end': 6, 'groups': list(), 'match': 'de', 'match-count': 1, 'start': 4)

11.7.10 regex-match-all(regex match pattern) : list

Name Definition
Definition Same as regex-match except that the "-all" will return a list where a match is made and then the pattern is applied to the rest of the string and the next match is made. The list contains a dictionary that contains the following keys:
end: The character position in the string where the match ended.
groups: Returns the groups used in the regular expression. Groups are defined using parenthesis in the pattern.
match: The text of the string that matched the regular expression pattern.
Match-count: The number of matches.
start: The character position in the string where the match started.
If there is no match, the match value is none and the match-count is zero.
Uses python regular expression variant.
Object string, uri
Parameters regex match pattern : string
Example 'abcdefg'.regex-match('de+')
Returns a list of: list(dict('end': 6, 'groups': list(), 'match': 'de', 'match-count': 1, 'start': 4))

11.7.11 regex-match-string(regex match pattern, optional group number) : string

Name Definition
Definition Returns the string that matches the regular expression pattern. If there is no match, the value is none. The second parameter allows the number of the group to be returned. Groups are defined in the pattern using parenthesis.Uses python regular expression variant.
Object string, uri
Parameters regex match pattern : string
optional group number : integer (optional)
Example 'abcdefg'.regex-match-string('de+')
Returns the string 'de'
'abcdefgabcdefg'.regex-match-string('(c)(d)', 2)
Returns 'd' because the '(d)' is the second group.

11.7.12 regex-match-string-all(regex match pattern, optional group number) : list

Name Definition
Definition The function is the same as regex-match-string except that the "-all" will return a list where a match is made and then the pattern is applied to the rest of the string and the next match is made. Uses python regular expression variant.
Object string, uri
Parameters regex match pattern : string
optional group number : integer (optional)
Example 'abcdefggabcdefg'.regex-match-string-all('[cf]([dg])')
Returns the list list(cd, fg, cd, fg)
'abcdefggabcdefg'.regex-match-string-all('[cf]([dg])', 1)
Returns list(d, g, d, g)

11.7.13 repeat(number of times to repeat) : string

Name Definition
Definition Repeats the string by the number of times defined in the parameter. The parameter is passed as an integer
Object string, uri
Parameters number of times to repeat : positive integer
Example '3'.repeat(4)
Returns a string of '3333'

11.7.14 replace(search string, replacement string, number of times) : string

Name Definition
Definition Returns a new string based on an existing string. Replaces the search string with the replacement string. The 3rd parameter indicates how many times to do the replace from left to right. If left off all search items will be replaced.
Object string, uri
Parameters Search string : string or none
Replacement string : string or none
Number of times : integer (optional)
Example 'Hello Mr Stains'.replace('Stains','Smith', 1)
Returns a string of 'Hello Mr Smith'

11.7.15 split(delimiter character(s)) : list

Name Definition
Definition Split a string into a list based on a delimiter character(s). If an empty string is used as the separator, the returned list will contain 1 item with the entire string.
Object string, uri
Parameters delimiter character : string
Example 'Hello Mr Stains'.split(' ')
Returns a string of list('Hello','Mr','Stains')

11.7.16 string() : string

Name Definition
Definition Converts a value to string using built-in formatting. For integers, decimals and floats, the built-in formatting includes comma thousand separators and a limit of 4 decimal places.
Object any
Example '1234.string
Returns a string value of '1,234'

11.7.17 plain-string() : string

Name Definition
Definition Converts a value to string without formatting.
Object any
Example '1234.plain-string
Returns a string value of '1234'

11.7.18 substring(begin index, end index) : string

Name Definition
Definition The substring(int beginIndex, int endIndex) returns a new string that is a substring of this string. The substring begins at the specified beginIndex and extends to the character at index endIndex. Thus the length of the substring is endIndex-beginIndex + 1. If the last parameter is left off it continues to the end of the string.
Object string, uri
Parameters Begin index : integer
End index : integer (optional)
Example 'Hello Mr. Stains'.substring(1,5)
Returns the string of 'Hello'

11.7.19 to-qname() : QName

Name Definition
Definition Converts a string to a QName. The string can include a prefix which is resolved using the namespace declarations. If the namespace cannot be resolved, the property will raise an error.
Object string
Example 'Abc'.to-qname
Returns a QName with local name 'abc' and the default namespace defined in the query set.

'us-gaap:Assets'.to-qname
Returns a QName with the namespace defined in the query set for prefix 'us-gaap' and local name 'Assets'.

11.7.20 trim(trim side) : string

Name Definition
Definition Trim removes white space from either the left side or right side or both sides of the string. The property has optional string values of 'left', 'right', or 'both'. If no value is provided the property defaults to both.
Object string, uri
Parameters Trim Side : string (optional) with values of either 'left', 'right' or 'both'
Example 'Abc '.trim
Returns a string without spaces at end.

'Abc '.trim('right')
Returns a string without spaces at end.

11.7.21 upper-case() : string

Name Definition
Definition Returns a string as uppercase characters.
Object string, uri
Example 'HTTP://some/role/for/cashflow/'.upper-case()
Returns the string as a uppercase string

11.8 General Properties and Functions

11.8.1 alignment() : dictionary

Name Definition
Definition Returns a dictionary of the alignment for the current iteration of a fact query. This function cannot be used as a property.
Example alignment()
Returns a dictionary with keys of entity, unit, period, concept, dimension and the associated values for the keys.

11.8.2 is-fact() : boolean

Name Definition
Definition Returns true or false if a value represents a fact object.
Object any
Example {@Assets}.is-fact
Returns true.

4.is-fact
Returns false.

11.8.3 document-location() : uri

Name Definition
Definition Returns the document uri of the document that contains the object. If there is no document uri, then it returns none
Object any object
Example {taxonomy().concepts(Assets).document-location
Returns the uri where the concept Assets is defined.

11.8.4 rule-name() : string

Name Definition
Definition rule-name returns the name of the current executing rule. The rule name is the generated rule name composed of the rule-name-prefix and rule-name-separator and the specific rule name if there is a rule-name prefix, otherwise it is just the specific rule name. It does not include a rule-suffix. When evaluating constants, the rule-name() returns none. This function cannot be used as a property.
Example output abc rule-name()
Returns 'abc' as a string.

11.8.5 unit(unit qname) : unit

Name Definition
Definition Defines a unit object based on the unit qname
Object none
Parameters unit qname : qname of the uit
Example unit(iso4217:USD)
Defines a unit object for USD.

11.9 Date Properties and Functions

11.9.1 contains(search duration) : boolean

Name Definition
Definition Is a property of a duration used to check if one duration period is contained within another duration period. If the values overlap a value of false is returned. Two matching durations will return true using contains.
Object duration
Parameters Search duration : duration or none
Example duration('2024-01-01','2025-01-01').contains(duration('2024-03-01','2024-06-01'))
Returns boolean value of true

11.9.2 date() : instant

Name Definition
Definition Pass this function a point in time string in the format yyyy-mm-dd to produce an instant date that can be compared to a fact. NOTE that a date fact is already a date type and should not be converted to a date.
Object string , instant
Example '2017-12-31'.date()
Converts the string to a date.

11.9.3 day() : integer

Name Definition
Definition Returns the day (integer) from a given date.
Object date
Example day(date('2017-12-31'))
Returns an integer value of 31.

11.9.4 days() : integer

Name Definition
Definition Returns the number of days in a duration object.
Object duration, time-period
Example duration('2022-01-01', '2022-03-31').days
Returns an integer of 90.

11.9.5 duration(start date, end date) : duration

Name Definition
Definition Returns a duration period type based on a start and end date provided as a date or string in the format YYYY-MM-DDT00:00:00. The hours minutes and seconds are optional. If not provided they default to 0. If both dates are the same the duration will be 0 days. Duration cannot be used as a property of a string.
Object No Object
Parameters Start date : date or string value in the format YYYY-MM-DDT00:00:00
End date : date or string value in the format YYYY-MM-DDT00:00:00
Example duration('2022-01-01', '2022-03-31')
Creates a duration type of 90 days.

11.9.6 month() : integer

Name Definition
Definition Returns the month (integer) from a given date.
Object date
Example month(date('2017-12-31'))
Returns an integer value of 12.

11.9.7 time-span() : time-period

Name Definition
Definition Allows a span of time to be defined for example time-span('P90D'). This uses the XML duration format to return the number of days in the period. This can also be used as a property of any duration.
Object duration, string in the XML duration format.
Example $document_period_end_date + (time-span("P4D"))
Adds 4 days to the value of document period end date.

11.9.8 year() : integer

Name Definition
Definition Returns the year (integer) from a fact or the year from a given date.
Object date
Example year(date('2017-12-31'))
Returns an integer value of 2017.

11.10 Existence Functions

11.10.1 exists(any object or fact) : boolean

Name Definition
Definition Tests for the existence of an object. If a fact object exists then a value of true is returned. If no facts exists in the instance then no value is returned as no fact iteration will be created. Exists is applicable for checking the existence of facts for each iteration. Exists will return a value of true when a none value is returned in a set or list. If a fact has a value of nil in the instance then exists returns true.
Object any
Parameters any object or fact : any - Tests that the object exists within the current alignment
Example exists({@Assets})
Tests if any fact value is not reported for assets. Covered needs to be used with missing if determining if the fact exists in the document at all.

11.10.2 missing(any object or fact) : boolean

Name Definition
Definition Tests for the existence of a fact. If a fact does not exist then a value of true is returned. This function cannot be used as a property.
Object any
Parameters any object or fact : any - Tests that the object exists within the current alignment
Example missing({covered @Assets})
Tests if any fact value is reported for assets and returns true.
missing(list())
Returns a value of false.

11.10.3 first-value(any, ...) : any

Name Definition
Definition Takes a list of expressions and returns the first expression that has a value. If no value is returned then no value is returned and the iteration is skipped. This is the same as a fact query that does not return any facts. I.e it is unbound. The function calculates values until it gets one that is not none. This function cannot be used as a property.
Object any
Parameters any object or fact : list of objects - Returns the first object in the list that exists within the current alignment
Example first-value({@Assets},{@CurrentAssets})
Returns the value of CurrentAssets if Assets is not present. If neither value is present then the iteration is skipped.
first-value({@Assets},0)
Returns the value of 0 if Assets is not present.

11.10.4 first-value-or-none(any, ...) : any

Name Definition
Definition Takes a list of expressions and returns the first expression that has a value. If no value is returned then no value is returned and a none value is returned. The function calculates values until it gets one that is not none. This function cannot be used as a property.
Object any
Parameters any object or fact : list of objects - Returns the first object in the list that exists within the current alignment
Example first-value-or-none({@Assets},{@CurrentAssets})
Returns the value of CurrentAssets if Assets is not present. If neither value is present then a none value is returned.
first-value({@Assets})
Returns the value of none if Assets is not present.

11.11 DTS Functions

11.11.1 qname(namespace, local-name) : QName

Name Definition
Definition Creates a valid QName by providing the namespace-uri and local name as parameters to the qname function. This function cannot be used as a property. No-namespace QNames are specified using this function with a value of skip for the namespace.
Object none
Parameters namespace : uri - uri of the QName namespace.
namespace : local-name - string representing the local-name of the QName.
Example qname($ext_namespace,'FairValueInputsLevel2AndLevel3Member')
Defines a qname based on the extension namespace.

11.11.2 taxonomy(entry-point url) : taxonomy object

Name Definition
Definition Creates a taxonomy object based on the taxonomy entry point url. If no parameter is passed the DTS of the current taxonomy is used. Used as a property of an instance document.
Object instance
Parameters entry-point url : uri - url is optional.
Example $US-GAAP = taxonomy('http://xbrl.fasb.org/us-gaap/2025/elts/us-gaap-2025-01-31.xsd')
Assigns the US-GAAP taxonomy object to the variable $US-GAAP

11.11.3 instance(instance url) : instance object

Name Definition
Definition Creates an instance object based on the instance url. If no parameter is passed the DTS of the current instance is used. The created instance object can then be queried using fact queries and object properties.
Object none
Parameters instance url : uri - url is optional.
Example $wsfs= instance('https://www.sec.gov/edgar/wsfs-20211231.htm')
Assigns the wsfs instance to the variable $wsfs

11.12 Set and List Properties and Functions

The following functions and properties can be applied to sets or lists.

11.12.1 all() : boolean

Name Definition
Definition Returns true if all values in a list or a set are true. An empty list or set returns true.
Object set, list
Collection type boolean
Example list(true,false,false,false).all
This will return false.

11.12.2 any() : boolean

Name Definition
Definition Returns true if any value is true in a list or a set. An empty list or set returns false.
Object set, list
Collection type boolean
Example any(list(true,false,false,false))
This will return true.

11.12.3 avg() : number

Name Definition
Definition Returns the average of values in a set or a list. The average of an empty list or set returns none.
Object set, list
Collection type number, numerical fact
Example avg(list({@PlanAssets @DefinedBenefitPlansDisclosuresDefinedBenefitPlansAxis = *}))
This will return the average value of plan assets across all plans.

11.12.4 denone() : any collection

Name Definition
Definition Removes none values from a list or set
Object set, list
Collection type any
Example denone(list(1,2,3,none,4)
This will return the list(1,2,3,4)

11.12.5 first() : any

Name Definition
Definition Returns the first value found in a list. The first of an empty list returns none.
Object list
Collection type any
Example first(list(1,2,3,4))
This will return the value of 1

11.12.6 last() : any

Name Definition
Definition Returns the last value found in a list. The last of an empty list returns none.
Object list
Collection type any
Example last(list(1,2,3,4))
This will return the value of 4

11.12.7 max() : number | string | fact

Name Definition
Definition Returns the maximum value in a set or list. This can be numerical, string or fact items. The function will return the fact object with the highest value. None cannot appear in the list.
Object set, list
Collection type number, string, fact - all of the same type
Example max(list({@concept = PlanAssets @@DefinedBenefitPlansDisclosuresDefinedBenefitPlansAxis = *}))
This will return the lowest value of the Plan Assets from all plans.

11.12.8 min() : number | string | fact

Name Definition
Definition Returns the minimum value in a set or list. This can be numerical, string or fact items. The function will return the fact object with the lowest value. None cannot appear in the list.
Object set, list
Collection type number, string, fact - all of the same type
Example min(list({@concept = PlanAssets @@DefinedBenefitPlansDisclosuresDefinedBenefitPlansAxis = *}))
This will return the lowest value of the Plan Assets from all plans.

11.12.9 prod() : number

Name Definition
Definition Returns the product of a set or a list. The prod of an empty list or set returns 1.
Object set, list
Collection type number, numerical fact
Example prod(list({@concept = PlanAssets @DefinedBenefitPlansDisclosuresDefinedBenefitPlansAxis = *}))
This will return the product of Plan Assets for every Plan member.

11.12.10 stdev() : number

Name Definition
Definition Returns the standard deviation of a set or a list. The stdev of an empty list or set returns none.
Object set, list
Collection type number, numerical fact
Example stdev(list({@PlanAssets @DefinedBenefitPlansDisclosuresDefinedBenefitPlansAxis = *}))
This will return the stdev value of plan assets across all plans.

11.12.11 sum() : any

Name Definition
Definition Returns the sum of a set or a list, this operates on any numerical and string type. Strings are concatenated. The sum of an empty list or set returns none. The sum of a set or list containing only none will return none.
Object set, list
Collection type number, string , fact or none - all of the same type
Example set(1,2,3,4).sum
sum(set(1,2,3,4))
Returns a number value of 10

11.12.12 contains(search item) : boolean

11.12.13 join(delimiter) : string

Name Definition
Definition Converts a set or a list to a string
Object set, list
Parameters delimiter : string - Defines the string character to insert between items in the set or list. This can be an empty string.
set $A = set('a','b','c')
Example $A.join(',')
Returns a a string value of "abc"

11.12.14 sort(sort order) : list

Name Definition
Definition Sorts a list or set, uses the argument 'desc' to sort descending and the 'asc' argument to sort ascending. If no parameter is provided, then the default sort is ascending. If a set is sorted it returns a list. All sort values must be the same type. If string and numbers are mixed the sort is done on string values.
Object list or set
Parameters sort order : Can be 'desc' or 'asc' (case-insensitive)
Example $A.sort('asc')
Returns a list of list(a,b,c).
$A.sort('desc')
Returns a list of list(c,b,a).

11.12.15 to-dict

Name Definition
Definition Converts a set or a list to a dictionary. If the set or list is empty the dictionary will be empty. If the list contains more than two items that represent the key value pairs then the list will be excluded from the resulting dictionary.
Object set or list
Collection type any
set $A= set(list('AAxis','AMember'), list('BAxis','BMember'))
Example $A.to-dict
Returns dict('AAxis'='AMember','BAxis'='BMember')

11.12.16 to-list

Name Definition
Definition Convert a set to a list.
Object set
Collection type any
set $B = set(a,b,c,d,e)
Example $B.to-list
Returns list(a,b,c,d,e)

11.12.17 agg-to-dict(dictionary index, ...)

Name Definition
Definition Aggregates a 2 dimensional collection (set/list of lists) to a dictionary. Arguments represent the index of the list that is used as the dictionary key. If there is no index a value of none is used for the key. This allows the collapse of a data structure into a dictionary that is easily referenced
Object list, set
Parameters dictionary index : integer - Must represent a valid position in the inner list. Multiple integers can be provided as arguments.
Collection type any
list $A = list(list('a', 'b', 'c'),list('e', 'f', 'g'),list('h', 'i', 'j'),list('a', 'x', 'y'))
Example $A.agg-to-dict(1)
Returns dictionary(a=list(list(a, b, c), list(a, x, y)),e=list(list(e, f, g)),h=list(list(h, i, j)))

Multiple integers can be passed as a dictionary key.

If multiple integer arguments are provided then the key becomes a list.

$i = list(list('a', 'b', 'c', 'd'),list('e', 'f', 'g'), list('h', 'i', 'j'), list('a', 'x', 'y'))

$i.agg-to-dict(1,4)

The resulting dictionary is as follows:

dictionary(list(a, d)=list(list(a, b, c, d)),list(e, None)=list(list(e, f, g)),list(h, None)=list(list(h, i, j)),list(a, None)=list(list(a, x, y)))

The key is created as a list. Some of the lists have 4 items and some have 3. In those cases where there is no value for the key, the value of none is used.

11.13 List Properties and Functions

11.13.1 Index(position in list) : any

Name Definition
Definition Return value in list based on an index. The index value starts at 1.
Object list
Parameters position in list : integer - Must represent a valid position in a list.
Collection type any
list $B = list(a,b,c,d,e)
Example $B.index(1)
Returns "a"

11.13.2 to-csv(col separator)

Name Definition
Definition Converts a list, or list of lists to a csv format. The separator is optional. A comma is the default if not supplied. The csv dialect is excel.
Object list
Parameters col separator : string - field separator such as comma or tab.
Collection type any
Example $A.to-csv(',')
creates a csv file format object.

11.13.3 to-set

Name Definition
Definition Convert list to a set
Object list
Collection type any
list $A = list(a,b,c,b))
Example $A.to-set(',')
creates a set of set(a,b,c).

11.14 Dictionary Properties and Functions

11.14.1 dict(lists of key value pairs) : dictionary

Name Definition
Definition Used to define a dictionary using a list with two values, the first is the key the second is the values.
Object none
Parameters lists of key value pairs : list - The list must have two values representing the key and the value of the dictionary item
Example $A = dict(list('AAxis','AMember'), list('BAxis','BMember'));

11.14.2 has-key(key to check for) : boolean

Name Definition
Definition Test if key is in dictionary.
Object dictionary
Parameters key to check for : any - key to test is in dictionary
Dictionary $A = dict(list('AAxis','AMember'), list('BAxis','BMember'));
Example $A.has-key('AAxis')
true

11.14.3 join(delimiter, dictionary pair delimiter) : string

Name Definition
Definition Convert a dictionary to a string.
Object dictionary
Parameters delimiter : string - Delimiter separating multiple key value pairs.
dictionary pair delimiter : string - Delimiter separating each key from its value.
Collection type any
Dictionary $A = dict(list('AAxis','AMember'), list('BAxis','BMember'));
Example $A.join(', ', '=')
Returns "AAxis=AMember , BAxis=BMember"

11.14.4 keys(value of key-value pair) : any

Name Definition
Definition Return a set of the key values in dictionary, can add a value to get matching keys as a set.
Object dictionary
Parameters value of key-value pair : any (optional) - Value associated with a key(s).
Collection type any
Dictionary $A = dict(list('AAxis','AMember'), list('BAxis','BMember'));
Example $A.keys
Returns set('AAxis', 'BAxis)
$A.keys('BMember')
*Returns set('BAxis')

11.14.5 values(key of key-value pair) : any

Name Definition
Definition Return a list of the values from key-value pairs as a set.
Object dictionary
Parameters key of key-value pair : any (optional) - key associated with a value.
Collection type any
Dictionary $A = dict(list('AAxis','AMember'), list('BAxis','BMember'));
Example $A.values
Returns set('AMember','BMember')
$A.values('BAxis')
*Returns set('BMember')

11.14.6 to-spreadsheet() : excel object

Name Definition
Definition Converts a dictionary with a list of lists to a spreadsheet format. Each key of the dictionary is created as a separate tab in the spreadsheet.
Object dictionary
Collection type any
Dictionary $A =dict(list(Sheet1,list(list(1))), list('sheet2',list(list(2))))
Example $A.to-spreadsheet
Returns the dictionary as a excel spreadsheet

11.14.7 to-json() : string

Name Definition
Definition Converts a list, set or dictionary to a json string format
Object set, list or dictionary
Collection type any
Dictionary $A =dict(list('AAxis','AMember'), list('BAxis','BMember'))
Example $A.to-json
Returns the dictionary as a json string

11.15 Range Functions

11.15.1 range(start, stop, step) : list

Name Definition
Definition The range function generates a list of integer numbers between the given start integer to the stop integer, which is generally used to iterate through a Loop. The range function accepts an integer and returns a list of integers. A single argument represents the stop integer, two arguments are the start and stop integers. The default start integer is 1. The default step integer is 1 unless specified otherwise. This function cannot be used as a property.
Object no object
Parameters start : integer
stop : integer
step : integer
Example range(5)
Returns a list of list(1,2,3,4,5).
range(4,10)
Returns list(4, 5, 6, 7, 8, 9, 10)
range(4,10,2)
Returns list(4, 6, 8, 10)

11.16 Data Import and Transformation Functions

11.17 csv-data(file-url, has headers, list of types, as dictionary) : list

Name Definition
Definition The function imports data from a csv file and returns a list of rows. The row is either a list or a dictionary (if the as dictionary parameter is supplied and true). If the list of types is supplied, no row can have more columns than the length of the list of types. If headers are in the file and returning as a dictionary, no row can have more columns than the header row. Types are defined as a list. I.e. list('string', 'date', 'date'). Formatted CSV files may use XBRL transforms to transform the CSV data to the appropriate type. (see Section 11.7.4) The transform and type are provided as a list i.e. list(ix4:date-day-month-year, 'date'). This function cannot be used as a property.
Object no object
Parameters file url : uri - Location and name of the csv file.
has headers : boolean - indicates if the csv file has headers.
list of types : list (optional) - If supplied it must have a type for each column. If omitted the columns will be strings. Possible values are string, date, decimal, float, int, boolean, or QName
as dictionary : boolean (optional) - If supplied and true, the result for the row will be a dictionary using the column names from the header as the key.
Example csv-data('https://xbrl.us/dqc_06_date_bounds.csv',true, list( 'string', 'string', 'string'))

Defines a csv file as a source of data.

csv-data('https://xbrl.us/trans.csv', true, list('string',list(ix4:num-dot-decimal, 'decimal'), list(ix4:date-day-month-year, 'date'), list(ix4:date-day-monthname-year-fr, 'date')))

Defines a csv format for a file format defined as follows:
name,amount,date,date2
Peter , '1,234,567.89' , 06/05/2020 , 05-juin-2020
Mary , '9,876.54' , 09/01/2019 , 01-septembre-2019

11.18 excel-data(file-url, range,has headers, list of types, as dictionary) : list

Name Definition
Definition The function imports data from an excel file and returns a list of rows. The row is either a list or a dictionary (if the as dictionary parameter is supplied and true). If the list of types is supplied, no row can have more columns than the length of the list of types. If headers are in the file and returning as a dictionary, no row can have more columns than the header row. Types are defined as a list. I.e. list('string', 'date', 'date'). Formatted excel files may use XBRL transforms to transform the excel data to the appropriate type. (see Section 11.7.4) The transform and type are provided as a list i.e. list(ix4:date-day-month-year, 'date'). This function cannot be used as a property.
Object no object
Parameters file url : uri - Location and name of the excel file.
range : string (optional) - This can be one of the following:
  • name of sheet,
  • named range,
  • cell range i.e sheet1!A1:D3
  • If not defined the range defaults to the active sheet. To add subsequent parameters a value of none must be provided.
    has headers : boolean (optional) - Boolean value that indicates if the range has header. If not provided the default is false.
    list of types : list (optional) - If supplied it must have a type for each column. If omitted the columns will be strings. Possible values are string, date, decimal, float, int, boolean, or QName
    as dictionary : boolean (optional) - If supplied and true, the result for the row will be a dictionary using the column names from the header as the key.
    Example excel-data('https://xbrl.us/excel-file.xls', 'sheet1!A1:D3',true,list('string',list(ix4:num-dot-decimal, 'decimal'), list(ix4:date-day-month-year, 'date'), list(ix4:date-day-monthname-year-fr, 'date')))

    Defines an excel data import for a file format defined as follows:
    name,amount,date,date2
    Peter , '1,234,567.89' , 06/05/2020 , 05-juin-2020
    Mary , '9,876.54' , 09/01/2019 , 01-septembre-2019

    11.19 json-data(file-url) : dictionary

    Name Definition
    Definition The function returns a dictionary which matches the structure of the json file. This function cannot be used as a property.
    Object no object
    Parameters file url : uri - Location and name of the json file.
    Example json-data('https://xbrl.us/json-file.json')
    Returns the json file as a dictionary.

    11.20 xml-data-flat(file-url, xpath to nodes, xpath fields, namespace maps) : list

    Name Definition
    Definition The function imports data from a flat xml file and returns a list of rows. The row is either a list or a dictionary (if the as dictionary parameter is supplied and true). If the list of types is supplied, no row can have more columns than the length of the list of types. If headers are in the file and returning as a dictionary, no row can have more columns than the header row. Types are defined as a list. I.e. list('string', 'date', 'date'). Formatted excel files may use XBRL transforms to transform the excel data to the appropriate type. (see Section 11.7.4) The transform and type are provided as a list i.e. list(ix4:date-day-month-year, 'date'. This function cannot be used as a property.)
    Object no object
    Parameters file url : uri - Location and name of the xml file.
    xpath to flat nodes : string - xpath expression to requested nodes.
    xpath return fields : list - list of xpath expressions to return defined nodes.
    list of types : list (optional) - There should be 1 for each field in the xpath return fields. If not supplied, the result will be a string Possible values are string, date, decimal, float, int, boolean, or QName.
    namespace maps : dictionary (optional) - The key is the prefix and the value is the namespace. The namespaces declared in the rule file are always available. Default namespaces are not supported. Any namespace must have a prefix.
    Example xml-data-flat('http://www.xbrl.org/lrr/lrr.xml','lrr:arcroles/lrr:arcrole', list('lrr:roleURI', 'lrr:status'))
    Returns a list of role URI and status.

    xml-data-flat('http://www.xbrl.org/lrr/lrr.xml', '/lrr:lrr', list('@version', 'lrr:status'), list('decimal', 'string'))
    The version number is converted to a decimal

    xml-data-flat('https://www.sec.gov/Archives/edgar/data/1099219/000162828023018062/ information_table.xml', 'j:infoTable', list('j:nameOfIssuer', 'j:titleOfClass', 'j:cusip','j:value'), list('string','string','string','decimal'), dict(list('j','http://www.sec.gov/edgar/document/thirteenf/informationtable')))
    Example showing namespace map

    12 Query Grammar

    12.1 Comments

    To define comments in a query the use the following:

    Chars Description
    /* Start a comment block
    */ End a comment block
    // Comment a single line

    12.2 Recognising QNames

    The grammar parser automatically identifies qnames. Because a period '.' is used to identify a property the parser cannot always accurately differentiate a QName from a property.

    If the qname contains a period then a backslash should be used to indicate that a period comprises the QName.

    For example:

        aapl:FixedRateRangefrom0.875to4.300 
    

    The example contains two periods. To identify this as a QName a backslash '\' is used to identify the period as a QName. i.e.:

        aapl:FixedRateRangefrom0\.875to4\.300
    

    12.3 EBNF

    QuerySet ::= ( QueryNameSeparator | QueryNamePrefix | NamespaceGroupDeclaration | NamespaceDeclaration | OutputAttributeDeclaration | FunctionDeclaration | ConstantDeclaration | MessageDefaultLanguage  | AssertDeclaration | OutputDeclaration )
    
    FunctionDeclaration
             ::= 'function' FunctionName '(' ( '$' ArgName ( ',' '$' ArgName  )* )? ')' FunctionBody
    
    FunctionName ::= SimpleName
    
    ArgName ::= SimpleName
    
    FunctionBody ::= Expr
    
    
    NamespaceGroupDeclaration ::= "namespace-group" NamespaceGroupName "=" Expr
    
    NamespaceDeclaration ::= 'namespace' (Prefix '=')? NamespaceURI 
    
    OutputAttributeDeclaration ::= "output-attribute" OutputAttributeName 
    
    NamespaceGroupName ::= SimpleName
    
    OutputAttributeName ::= SimpleName
    
    ConstantDeclaration ::= 'constant' '$' ConstantName "=" Expr 
    
    ConstantName ::= SimpleName
    
    AssertDeclaration ::= "assert" NCName ( "satisfied" | "unsatisfied" )? Expr QueryResult* 
    
    OutputDeclaration ::= "output" NCName Expr QueryResult*
    
    QueryResult ::= ( ( ("message" LanguageExpr?) | "severity" | "query-suffix" | "query-focus" | OutputAttributeName  ) Expr ) 
    
    LanguageExpr ::= Expr
    
    Expr ::= FuncRef | VarRef | BlockExpr | PropertyExpr | IndexExpr | TaggedExpr | IfExpr | ForExpr | Navigate | Filter | FactQuery | UnaryExpr | BinaryExpr  | FloatLiteral | IntegerLiteral | StringLiteral | BooleanLiteral | SeverityLiteral | BalanceLiteral | PeriodTypeLiteral | NoneLiteral | SkipLiteral | ForeverLiteral | QName
    
    FuncRef ::= FunctionName '(' (Expr (',' Expr )* )* ')'
    
    VarRef ::= '$' VarName
    
    VarName ::= SimpleName
    
    BlockExpr ::= VarDeclaration ( VarDeclaration)* Expr
    
    VarDeclaration ::= '$' VarName '=' Expr ";"?
    
    IndexExpr ::= Expr '[' Expr ']'
    
    TaggedExpr ::= Expr '#' SimpleName
    
    IfExpr ::= 'if' ConditionExpr Expr 'else' Expr 
    
    ForExpr ::= 'for' '$' VarName 'in' Expr Expr
    
    BinaryExpr ::= Expr ("*" | "/" | "+>" | "->" | "+" | "-" | "<+>" | "<+" | "<->" | "<-" | "^" |"&" | "intersect"| "==" | "!=" | "<=" | "<" | ">=" | ">" | 'in' | ( 'not' 'in') | 'and' | 'or' ) Expr
    
    UnaryExpr ::= ('+'| '-'| 'not') Expr
    
    
    Navigate ::= 'navigate' ('dimensions' | 'across networks')?
    Arcrole? Direction 
    'include start'? 
    ('from' Concept)? 
    ('to' Concept)?
    ('stop when' Expr)? 
    ('role' Role)? 
    ('drs-role' DRSRole)?
    ('linkbase' Linkbase)? 
    ('cube' Hypercube)? 
    ('taxonomy' Taxonomy)? 
    ('where' Expr)?
    ('returns' ('by network')? ( 'list' | 'set' )? 
              'paths'? (ReturnComponents ('as' ('dictionary' | 'list'))?) )?
    
    
    ReturnComponents ::=  '('? (ReturnComponent (',' ReturnComponent )* )* ')'?
    
    ReturnComponent ::= ('source' | 'source-name' | 'target' | 'target-name' | 'order' |
                        'weight' | 'preferred-label' | 'preferred-label-role' | 'relationship'|
                        'role' |'role-description' | 'arcrole' | 'arcrole-uri'|'arcrole-description'|
                        'arcrole-cycles-allowed'| 'link-name' |'arc-name' |'network'|
                        'cycle' | 'navigation-order' | 'navigation-depth' | 'result-order' |
                        'dimension-type' | 'dimension-sub-type' | 'drs-role' | QName)
    
    Arcrole ::= Expr
    
    Role ::= Expr
    
    Taxonomy ::= Expr
    
    Concept ::= Expr
    
    Linkbase ::= Expr
    
    Hypercube ::= Expr
    
    DRSRole ::= Expr
    
    
    Direction ::= 'descendants' | 'children' | 'ancestors' | 'parents' | 'sibling' | 'previous-siblings' | 'next-siblings' 
    
    ConditionExpr ::= Expr
    
    PropertyExpr ::= Expr '.' PropertyName
    
    PropertyName ::= SimpleName
    
    Filter ::= 'filter' Expr ('where' Expr)? ('returns' Expr)? 
    
    FactQuery ::= 
    ('{' FactQueryBody '}') |
    ('[' FactQueryBody ']') |
    (FactQueryBody) 
    
    FactQueryBody ::=  ('covered'|'covered-dims')? (('nils' 'nildefault'?)|('nildefault'?)|'nonils')? (DimensionFilter)* ('where' Expr)?
    
    DimensionFilter ::= ('@' | '@@') (DimensionName (('=' DimensionExpr)?| ('!=' DimensionExpr)?| ('in'  DimensionExpr)? |('not in' DimensionExpr)?)  ('as' NCName)? )?
    
    DimensionName ::= ('concept' | 'unit' | 'entity' | 'period' | TaxonomyDimension | 'cube' | 'dimension'| 'instance' | 'language')
    
    StringLiteral   ::= '"' [^"]* '"' | "'" [^']* "'"
    
    NameStartChar
             ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
    
    NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
    
    Name     ::= NameStartChar (NameChar)*
    
    NCName   ::= Name - (Char* ':' Char*)
              /* An XML Name, minus the ":" */
    
    QName    ::= PrefixedName
               | UnprefixedName
    
    PrefixedName
             ::= Prefix ':' LocalPart
    
    UnprefixedName
             ::= LocalPart
    
    Prefix   ::= NCName
    
    LocalPart
             ::= NCName
    
    SimpleName ::= NameStartChar (SimpleNameChar)*
    
    SimpleNameChar ::= NameStartChar | "-" | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
    
    Sign ::= "+" | "-"
    
    SciNot ::= "e"
    
    DecimalPoint ::= "."
    
    Digits ::= [0-9]+
    
    IntegerPart ::= sign digits
    
    IntegerLiteral ::= integerPart
    
    InfLiteral ::= sign "INF"
    
    FloatLiteral ::= ( ( DecimalPoint Digits SciNot IntegerPart ) |
                        ( IntegerPart DecimalPoint Digits [0-9]* SciNot IntegerPart ) |
                        InfLiteral ) "float"
    
    StringEscape ::= "\\"
    
    StringExpr ::= "{" Expr "}"
    
    
    BooleanLiteral ::= ( "true" | "false" ) 
    
    NoneLiteral ::= "none"
    
    SkipLiteral ::= "skip"
    
    ErrorLiteral ::= "error"
    
    WarningLiteral ::= "warning"
    
    OkLiteral ::= "ok"
    
    PassLiteral ::= "pass"
    
    SeverityLiteral ::= ( ErrorLiteral | WarningLiteral | OkLiteral | PassLiteral )
    
    BalanceLiteral ::= ( "debit" | "credit" )
    
    PeriodTypeLiteral ::= ( "instant" | "duration" )
    
    ForeverLiteral ::= "forever"
    

    Appendix A Properties

    Property Name Parameters (-ve is optional) Object Applies To Parameters
    abs 0 int, float, decimal, fact
    agg-to-dict 1 or more Set of lists, list of lists
    all 0 list, set
    all-labels 0 concept, fact
    all-references 0 concept all-references, fact all-references
    any 0 list, set
    arc-name 0 relationship arc-name
    arcrole 0 network arcrole, relationship arcrole, footnote arcrole
    arcrole-description 0 network arcrole-description, relationship arcrole-description
    arcrole-uri 0 network arcrole-uri, relationship arcrole-uri
    attribute 1 concept, relationship
    avg 0 list, set
    balance 0 concept balance
    base-type 0 concept base-type, fact base-type
    clark 0 Qname, concept, fact, reference-part
    concept -1 fact, taxonomy, dimension
    concept-names 0 taxonomy concept-names, network concept-names
    concepts 0 taxonomy concepts, network concepts
    contains 1 list, set, string, uri
    content 0 footnote content
    cube 2 taxonomy
    cube-concept 0 cube cube-concept
    cubes 0 taxonomy cubes
    data-type 0 concept data-type, fact data-type
    date 0 string
    day 0 instant
    days 0 instant, duration
    decimal 0 Int, float, decimal, string, fact
    decimals 0 fact decimals
    default 0 dimension default
    denominator 0 unit denominator
    description 0 role description
    difference 1 set set
    dimension 1 fact, taxonomy qname
    dimension-type 0 dimension dimension-type
    dimensions 0 fact dimensions, cube dimensions, taxonomy dimensions
    dimensions-explicit 0 fact dimensions-explicit, cube dimensions-explicit, taxonomy dimensions-explicit
    dimensions-typed 0 fact dimensions-typed, cube dimensions-typed, taxonomy dimensions-typed
    document-location all
    drs-role 0 cube drs-role
    dts-document-locations 0 taxonomy dts-document-locations
    effective-weight 2 taxonomy qname, qname
    effective-weight-network -3 taxonomy qname, qname, network
    end 0 instant end, duration end
    entity 0 fact entity
    entry-point 0 taxonomy entry-point
    entry-point-namespace 0 taxonomy entry-point-namespace
    enumerations 0 type enumerations, concept enumerations, fact enumerations
    fact 0 footnote fact
    facts 0 Cube facts, instance facts
    first 0 list, set
    footnotes 0 fact footnotes
    has-enumerations 0 type has-enumerations, concept has-enumerations, fact has-enumerations
    has-key 1 dictionary
    id 0 entity id, unit id, fact id
    index 1 list, dictionary
    index-of 1 string, uri
    inline-ancestors 0 fact inline-ancestors
    inline-children 0 fact inline-children
    inline-descendants 0 fact inline-descendants
    inline-display-value 0 fact inline-display-value
    inline-format 0 fact inline-format
    inline-hidden 0 fact inline-hidden
    inline-negated 0 fact inline-negated
    inline-parents 0 fact inline-parents
    inline-scale 0 fact inline-scale
    inline-transform -2 string
    instance 0 fact instance
    int 0 Int, float, decimal, string, fact
    intersect 1 set
    is-abstract 0 concept is-abstract
    is-fact 0 fact is-fact
    is-monetary 0 concept is-monetary, fact is-monetary
    is-nil 0 fact is-nil
    is-numeric 0 concept is-numeric, fact is-numeric
    is-subset 1 set
    is-superset 1 set
    is-type 1 concept, fact
    join -2 list, set, dictionary string, string
    keys -1 dictionary
    label -2 concept, fact
    lang 0 label lang, footnote lang
    last 0 list, set
    last-index-of 1 string, uri Integer
    length 0 list, set, string, uri, dictionary
    link-name 0 relationship link-name
    local-name 0 qname local-name, concept local-name, fact local-name, reference-part local-name
    log10 0 int, float, decimal, fact
    lower-case 0 string, uri
    max 0 list, set
    min 0 list, set
    mod 1 int, float, decimal, fact int, float, decimal, fact
    month 0 instant
    name 0 fact name, concept name, reference-part name, type name
    namespaces 0 taxonomy namespaces
    namespace-map 0 fact namespace-map
    namespace-uri 0 qname namespace-uri, concept namespace-uri, fact namespace-uri, reference-part namespace-uri
    network 0 relationship network
    networks -2 taxonomy networks
    number 0 int, float, decimal, fact
    numerator 0 unit numerator
    order 0 relationship order, reference-part order
    part-by-name 1 reference
    part-value 0 reference-part part-value
    parts 0 reference parts
    period 0 fact period
    period-type 0 concept period-type
    plain-string 0 all
    power 1 int, float, decimal
    preferred-label 0 relationship preferred-label
    primary-concepts 0 cube primary-concepts
    prod 0 list, set
    references -1 concept, fact uri
    regex-match 1 string, uri string
    regex-match-all 1 string, uri string
    regex-match-string -2 string, uri string, number
    regex-match-string-all -2 string, uri string, number
    relationships 0 network relationships
    role 0 network role, label role, reference role, relationship role
    roots 0 network roots
    round 1 int, float, decimal, fact int, float, decimal, fact
    scheme 0 entity scheme
    sid 0 fact sid
    signum 0 int, float, decimal, fact
    sort -1 list, set string enum = 'ASC', 'DESC'
    source 0 relationship source
    source-concepts 0 network source-concepts
    source-name 0 relationship source-name
    split 1 string, uri string
    start 0 instant start, duration start
    stdev 0 list, set
    string 0 all
    substitution 0 concept substitution, fact substitution
    substring -2 string, uri
    sum 0 list, set
    symmetric-difference 1 set
    target 0 relationship target
    target-concepts 0 network target-concepts
    target-name 0 relationship target-name
    taxonomy 0 instance taxonomy
    text 0 label text
    time-span 0 String, duration
    to-csv 1 list
    to-dict 0 list, set
    to-json 0 list, set, dictionary
    to-list 0 list, set
    to-qname 0 string
    to-set 0 list, set, dictionary
    to-spreadsheet 0 dictionary
    trim -1 string, uri string enum = 'left', 'right','both'
    trunc -1 int, float, decimal, fact
    union 1 set
    unit 0 fact unit
    upper-case 0 string, uri
    uri 0 role uri, taxonomy uri
    used-on 0 role used-on
    values 0 dictionary
    weight 0 relationship weight
    year 0 instant

    Appendix B Functions that are not Properties

    Function Name Parameters Optional Parameters Parameters
    alignment 0 0 Used to get the alignment of a fact.
    csv-data 4 2 File url, has headers, list of types, output as dictionary
    dict Define a dictionary
    duration 2 0 Start date, end date
    excel-data 5 4 File url, range, has headers,list of types, output as dictionary
    exists 1 0 Object to test exists.
    first-value unlimited Must have at least one parameter
    first-value-or-none unlimited Must have at least one parameter
    json-data 1 0 File url
    missing 1 0 Object to test is missing..
    qname 2
    random 1 1 Number of decimal places, defaults to 4 if none provided
    rule-name 0 0 Returns the rule name.
    range 3 2 Accepts integers the first is the stop, the second is the start and the third is the step.
    xml-data-flat 5 3 File url, xpath expression, xpath expressions return,list of return types, output as dictionary

    Appendix C Examples

    C.1 Example 1: Sum a Dimension

    The following expression defines a rule that checks that PropertyPlantAndEquipmentGross equals the sum of the dimension PropertyPlantAndEquipmentByTypeAxis.

    ASSERT US.0187.10173 satisfied
    $rule_id = (rule-name().split('.'))[rule-name().split('.').length];
    
    $ppe_gross = {nonils @concept=PropertyPlantAndEquipmentGross};
    $ppe_Gross_dim_components = list({nonils @concept=PropertyPlantAndEquipmentGross @PropertyPlantAndEquipmentByTypeAxis=*});
    $ppe_Gross_dim_components_sum = sum($ppe_Gross_dim_components)
    
    if $ppe_Gross_dim_components_sum == none
        skip
    else
        $ppe_gross < $ppe_Gross_dim_components_sum
    
    message
    "The value of PropertyPlantAndEquipmentGross is reported as {$ppe_gross}. The dimensional breakdown of PropertyPlantAndEquipmentGross using the axis PropertyPlantAndEquipmentByTypeAxis aggregates to a total of {$ppe_Gross_dim_components_sum}.  This is more than the value of PropertyPlantAndEquipmentGross.
    
    The dimensional values reported are as follows:
    {$ppe_Gross_dim_components.join(', ')}
    
    Rule Element Id:{$rule_id}
    "
    
    severity error
    rule-focus $ppe_gross
    

    C.2 Example 2: Check if a Member has Descendants

    The following expression checks if the member NonrelatedPartyMember has an descendants defined in the filing.

    ASSERT US.0160.10082 satisfied
    
    $rule_id = (rule-name().split('.'))[rule-name().split('.').length];
    
    $NonRelatedPartyMemberDescendants = navigate domain-member descendants from NonrelatedPartyMember returns (target-name)
    
    $NonRelatedPartyMemberDescendants.length > 0
    
    message
    "The filer has reported descendant members of the  member NonrelatedPartyMember. This member cannot have any descendants and is only to be used to show the non related party portion of a balance containing related party components. The descendant members are as follows: {$NonRelatedPartyMemberDescendants.join(', ')}.
    
    Rule Element Id:{$rule_id}
    "
    
    SEVERITY error
    

    Appendix D Document history

    See specifications.xbrl.org for a list of public releases of this specification.

    Appendix E Errata Corrections incorporated in this document

    This appendix contains a list of the errata that have been incorporated into this document. This represents all those errata corrections that have been approved by the XBRL International Open Information Model Working Group (SWG) up to and including 2024-06-11.

    No errata have been incorporated into this document.

    Appendix F Intellectual property status (non-normative)

    This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this paragraph are included on all such copies and derivative works. However, this document itself may not be modified in any way, such as by removing the copyright notice or references to XBRL International or XBRL organizations, except as required to translate it into languages other than English. Members of XBRL International agree to grant certain licenses under the XBRL International Intellectual Property Policy (https://www.xbrl.org/legal).

    This document and the information contained herein is provided on an "AS IS" basis and XBRL INTERNATIONAL DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.

    The attention of users of this document is directed to the possibility that compliance with or adoption of XBRL International specifications may require use of an invention covered by patent rights. XBRL International shall not be responsible for identifying patents for which a license may be required by any XBRL International specification, or for conducting legal inquiries into the legal validity or scope of those patents that are brought to its attention. XBRL International specifications are prospective and advisory only. Prospective users are responsible for protecting themselves against liability for infringement of patents. XBRL International takes no position regarding the validity or scope of any intellectual property or other rights that might be claimed to pertain to the implementation or use of the technology described in this document or the extent to which any license under such rights might or might not be available; neither does it represent that it has made any effort to identify any such rights. Members of XBRL International agree to grant certain licenses under the XBRL International Intellectual Property Policy (https://www.xbrl.org/legal).