# Function definition 1.0

## Recommendation 22 June 2009

Copyright ©2009 XBRL International Inc., All Rights Reserved.

This version:
  <http://www.xbrl.org/Specification/functionDefinition/REC-2009-06-22/functionDefinition-REC-2009-06-22.html>
Editors:
  Geoff Shuetrim, Galexy <geoff@galexy.net>
  Herm Fischer, UBMatrix / Mark V Systems <fischer@markv.com>

## Status

Circulation of this Recommendation is unrestricted. This document is normative. Recipients are invited to submit comments to formula-feedback@xbrl.org, and to submit notification of any relevant patent rights of which they are aware and provide supporting documentation.

## Abstract

This specification is defines a syntax for an XML resource that contains information about an XBRL function. Such resources can be referenced from the XBRL function registry.

### Comment

# 1 Introduction

This specification is defines a syntax for an XML resource that contains information about an XBRL function. Such resources can be referenced from the XBRL function registry. [Geoff Shuetrim: When published as a recommendation, there could be a URL for the function registry document here. ]

## 1.1 Background

This specification is intended to support the creation, maintenance, and publication of XBRL function definitions.

## 1.2 Relationship to other work

This specification works with the XBRL registry specification.

## 1.3 Language independence

The official language of XBRL International's own work products is English and the preferred spelling convention is UK English.

## 1.4 Terminology

This specification is consistent with the definitions of any of the terms defined in specifications that it depends on.

## 1.5 Document conventions (non-normative)

Documentation conventions follow those set out in the XBRL Variables Specification [VARIABLES].

## 1.6 Namespaces and namespace prefixes

Namespace prefixes [XML NAMES] will be used for elements and attributes in the form `ns:name` where `ns` is the namespace prefix and `name` is the local name. Throughout this specification, the mappings from namespace prefixes to actual namespaces is consistent with Table 1.

The prefix column in Table 1 is non normative. The namespace URI column is normative.

Table 1: Namespaces and namespace prefixes

Prefix | Namespace URI
--- | ---
`fcn` | `http://xbrl.org/2008/function`
`xqt-err` | `http://www.w3.org/2005/xqt-errors`
`xml` | `http://www.w3.org/XML/1998/namespace`
`xlink` | `http://www.w3.org/1999/xlink`

# 2 Syntax

This specification only provides a textual declaration of syntax constraints when those constraints are not expressed by the normative schema supplied with this specification.

Explanations of elements and attributes are only supplied when explanations are not already provided in other specifications.

Unless explicitly stated otherwise, a reference to a specific element MUST be read as a reference to that element or to any element in its substitution group .

## 2.1 Function definition

A function definition is an XML resource with the `<fcn:function>` element as its root.

Function definitions are intended to be referenced by registry entries.

Any attribute in the XML namespace (`http://www.w3.org/XML/1998/namespace`) MAY be used on any element within a function definition.

The `@xml:lang` attribute MAY be used to indicate the language used to express information in the registry, as per the XML Specification [XML].

The `@xml:base` attribute MAY be used when resolving URIs as per the XML Base Specification [XMLBASE].

### 2.1.1 Element: lastUpdated

The `<fcn:lastUpdated>` element contains a `@moment` attribute whose value is the instant on which the function definition was last updated.

### 2.1.2 Element: owners

The `<fcn:owners>` element contains one or more `<reg:owner>` elements, as defined in the XBRL registry specification [REGISTRY].

Each owner is a person with responsibility for maintaining the function definition.

### 2.1.3 Element: summary

The `<fcn:summary>` element contains a brief text summary of the function.

### 2.1.4 Element: documentation

The optional `<fcn:documentation>` element contains either a URL that resolves to documentation of the function or it contains XHTML [XHTML] markup documenting the function.

If the documentation is provided as a URL, then the URL is specified using a `<reg:url>` element that conforms to the registry documentation syntax rules..

### 2.1.5 Element: reference

The `<fcn:reference>` element contains a link to a a part of a specification that is relevant to the function being defined.

The `<fcn:reference>` element contains an `@xlink:type` attribute that equals `simple` and an `@xlink:href` attribute that contains a URI that MUST resolve to the part of the specification being referenced.

The `<fcn:reference>` element MAY contain string content documenting the nature of the resource that the URL is linking to.

A function definition MAY contain several references, if the function is related to several aspects of a specification or several specifications.

### 2.1.6 Element: signature

The `<fcn:signature>` element contains the signature of the function being defined.

The `@name` attribute on the function signature contains the QName that uniquely identifies the function.

The `@output` attribute on the function signature contains the data type of the output expected from the function. In function signatures, data type names follow those used in XQuery 1.0 and XPath 2.0 [].

A function signature MAY also contain one or more `<fcn:input>` elements that specify each of the function's parameters. There MUST be one such element for each parameter. The document order of the elements MUST match the order of the parameters as they are used in calls to the function being defined.

Error code xqt-err:XPST0017, the XPath 2.0 number of parameters error, MUST be thrown if the number of parameters used in a function call does not match the number of `<fcn:input>` elements defined for the function.

#### 2.1.6.1 Element: input

The `<fcn:input>` element summarises an input parameter for the function being defined.

The `@name` attribute on the function signature contains a name for the parameter.

The `@type` attribute on the function signature contains the parameter's data type.

XHTML content of the `<input>` element can be used to provided additional explanation of the parameter.

Error code xqt-err:XPTY0004, the XPath 2.0 type mismatch error, MUST be thrown if an input has a type that does not match the parameter's data type.

#### 2.1.6.2 Element: output

The `<fcn:output>` element summarises the output of the function being defined.

The `@type` attribute on the function signature contains the parameter's data type.

XHTML content of the `<output>` element can be used to provided additional explanation of the function output.

### 2.1.7 Element: error

If a function is misused, it may be necessary to produce an error message. These messages are defined by the `<fcn:error>` elements that follow the function signature.

The `<fcn:error>` element contains information about an error that MUST be thrown under specific circumstances when a function is called.

The XHTML content of the `<fcn:error>` element defines the circumstances under which the error is required to be thrown.

The `@code` attribute contains the QName that uniquely identifies the error.

### 2.1.8 Element: example

The `<fcn:example>` element can be used to provide an example of function usage.

The `@title` attribute contains the title of the example.

The `@usage` attribute contains the example function usage.

The XHTML content of the `<fcn:example>` element explains the result of such usage.

### 2.1.9 Element: conformance-test

The `<fcn:conformanceTest>` element contains a link to a conformance suite test that MUST be passed by software claiming to implement the function being defined.

The `<fcn:conformanceTest>` element contains an `@xlink:type` attribute that equals `simple` and an `@xlink:href` attribute that contains a URI that MUST resolve to the conformance test resource.

### 2.1.10 Element: revisions

The `<reg:revisions>` element conforms to the XBRL registry specification [REGISTRY].

# Appendix A Normative schema

The following is the XML schema provided as part of this specification. This is normative. Non-normative versions (which should be identical to these except for appropriate comments indicating their non-normative status) are also provided as separate files for convenience of users of the specification.

NOTE: (non-normative) Following the schema maintenance policy of XBRL International, it is the intent (but is not guaranteed) that the location of non-normative versions of these schemas on the web will be as follows:

1. While any schema is the most current RECOMMENDED version and until it is superseded by any additional errata corrections a non-normative version will reside on the web in the directory `http://www.xbrl.org/2008/` - during the drafting process for this specification this directory should contain a copy of the most recent published version of the schema at http://www.xbrl.org/2008/function.xsd.
2. A non-normative version of each schema as corrected by any update to the RECOMMENDATION will be archived in perpetuity on the web in a directory that will contain a unique identification indicating the date of the update.

<schema xmlns:fcn="http://xbrl.org/2008/function" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:reg="http://xbrl.org/2008/registry" xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://xbrl.org/2008/function" elementFormDefault="qualified" xsi:schemaLocation="http://www.w3.org/2001/XMLSchema http://www.w3.org/2001/XMLSchema.xsd">
<import namespace="http://xbrl.org/2008/registry" schemaLocation="registry.xsd"/>
<element id="xml-function" name="function">
<complexType>
<sequence>
<element id="xml-last-updated" name="lastUpdated" type="reg:date.elt.type"/>
<sequence maxOccurs="unbounded">
<element id="xml-owners" name="owners" type="reg:owners.elt.type"/>
<element id="xml-summary" name="summary" type="string"/>
<element id="xml-documentation" name="documentation" type="reg:documentation.elt.type" minOccurs="0"/>
<element id="xml-reference" name="reference" type="reg:url.elt.type" minOccurs="0" maxOccurs="unbounded"/>
<element id="xml-signature" name="signature" type="fcn:signature.elt.type" maxOccurs="unbounded"/>
<element id="xml-error" name="error" type="fcn:error.elt.type" minOccurs="0" maxOccurs="unbounded"/>
<element id="xml-example" name="example" type="fcn:example.elt.type" minOccurs="0" maxOccurs="unbounded"/>
<element id="xml-conformance-test" name="conformanceTest" type="reg:url.elt.type" minOccurs="0" maxOccurs="unbounded"/>
<element id="xml-revisions" name="revisions" type="reg:revisions.elt.type"/>
</sequence>
</sequence>
<attributeGroup ref="reg:common.attribute.group"/>
</complexType>
</element>
<complexType name="signature.elt.type">
<sequence>
<element id="xml-input" name="input" type="fcn:input.elt.type" minOccurs="0" maxOccurs="unbounded"/>
<element id="xml-output" name="output" type="fcn:output.elt.type"/>
</sequence>
<attribute name="name" type="QName" use="required"/>
<attributeGroup ref="reg:common.attribute.group"/>
</complexType>
<complexType name="input.elt.type">
<sequence>
<any namespace="http://www.w3.org/1999/xhtml" processContents="skip" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="type" type="string" use="required"/>
<attribute name="name" type="string" use="required"/>
<attributeGroup ref="reg:common.attribute.group"/>
</complexType>
<complexType name="output.elt.type">
<sequence>
<any namespace="http://www.w3.org/1999/xhtml" processContents="skip" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="type" type="string" use="required"/>
<attributeGroup ref="reg:common.attribute.group"/>
</complexType>
<complexType name="error.elt.type">
<sequence>
<any namespace="http://www.w3.org/1999/xhtml" processContents="skip" maxOccurs="unbounded"/>
</sequence>
<attribute name="code" type="QName" use="required"/>
<attributeGroup ref="reg:common.attribute.group"/>
</complexType>
<complexType name="example.elt.type">
<sequence>
<any namespace="http://www.w3.org/1999/xhtml" processContents="skip" maxOccurs="unbounded"/>
</sequence>
<attribute name="title" type="QName" use="required"/>
<attribute name="usage" type="QName" use="required"/>
<attributeGroup ref="reg:common.attribute.group"/>
</complexType>
</schema>

# Appendix B References

REGISTRY
  XBRL International Inc.. "XBRL Registry 1.0"
  Geoff Shuetrim.
  (See registry-PWD-2008-12-31.html)
VARIABLES
  XBRL International Inc.. "XBRL Variables 1.0"
  Phillip Engel, Herm Fischer, Victor Morilla, Jim Richards, Geoff Shuetrim, David vun Kannon, and Hugh Wallis.
  (See http://www.xbrl.org/Specification/variables/REC-2009-06-22/variables-REC-2009-06-22.html)
XHTML
  W3C (World Wide Web Consortium). " XHTML™ 1.0 The Extensible HyperText Markup Language (Second Edition)"
  (See http://www.w3.org/TR/xhtml1/)
XML
  W3C (World Wide Web Consortium). "Extensible Markup Language (XML) 1.0 (Fourth Edition)"
  Tim Bray, Jean Paoli, C. M. Sperberg-McQueen, Eve Maler, and François Yergeau.
  (See http://www.w3.org/TR/REC-xml/)
XML NAMES
  W3C (World Wide Web Consortium). "Namespaces in XML 1.0 (Second Edition)"
  Tim Bray, Dave Hollander, Andrew Layman, and Richard Tobin.
  (See http://www.w3.org/TR/REC-xml-names/)
XML SCHEMA STRUCTURES
  W3C (World Wide Web Consortium). "XML Schema Part 1: Structures Second Edition"
  Henry S. Thompson, David Beech, Murray Maloney, and Noah Mendelsohn.
  (See http://www.w3.org/TR/xmlschema-1/)
XMLBASE
  W3C (World Wide Web Consortium). "XML Base"
  Johnathan Marsh.
  (See http://www.w3.org/TR/xmlbase/)
XPATH 2.0
  W3C (World Wide Web Consortium). "XML Path Language (XPath) 2.0"
  Anders Berglund, Scott Boag, Don Chamberlin, Mary F. Fernández, Michael Kay, Jonathan Robie, and Jérôme Siméon.
  (See http://www.w3.org/TR/xpath20/)

# Appendix C 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 (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 (www.xbrl.org/legal).

# Appendix D Acknowledgements (non-normative)

This document could not have been written without the contributions of many people including the participants in the FWG.

# Appendix E Document history (non-normative)

Date | Author | Details
--- | --- | ---
17 January 2008 | Geoff Shuetrim | First internal working draft created.
29 January 2008 | Geoff Shuetrim | Added in element documentation to the initial skeleton draft based on the normative schema.
30 January 2008 | Geoff Shuetrim | Relaxed the requirement that data types for function signatures be expressed as QNames given the need to deal in sequences.
31 January 2008 | Geoff Shuetrim | Adapted hyperlinks to use XLink simple link syntax.
04 February 2008 | Geoff Shuetrim | Added error code details and created more structure for information about input parameters of the function being defined.
12 June 2010 | Herm Fischer | Errata 1: Added XPath 2.0 error code references for wrong number of parameters and mismatched type of parameter in function call.

# Appendix F Errata corrections 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 FWG up to and including 22 June 2009. Hyperlinks to relevant e-mail threads may only be followed by those who have access to the relevant mailing lists. Access to internal XBRL mailing lists is restricted to members of XBRL International Inc.

No errata have been incorporated into this document.