XBRL Formula 1.0 Specification
Public Working Draft, dated 2007-07-13
Copyright © 2006-7, XBRL International Inc., All Rights Reserved
This version:
Formula-PWD-2007-07-13.rtf
is NORMATIVE. All other versions and formats are non-normative.
Editors
Name	Contact	Affiliation	
Phillip Engel	phillip.engel@morganstanley.com 	Morgan Stanley	
Geoff Shuetrim	geoff@galexy.net	Galexy	
David vun Kannon	david.k.vunkannon@us.pwc.com 	PricewaterhouseCoopers LLP	
Hugh Wallis	hughwallis@xbrl.org	XBRL International Inc.	
Contributors
Name	Contact	Affiliation	
Walter Hamscher	walter@hamscher.com	Standard Advantage / Consultant to PricewaterhouseCoopers LLP	
David Jeffery	david.jeffery@ubmatrix.com	UBmatrix	
Chris Simmons	cps@decisionsoft.com	DecisionSoft	
Abstract
This specification is an optional modular extension of the XBRL 2.1 Specification [XBRL].  It enables XBRL taxonomies to include declarations of formulae that operate on XBRL data.
Status
This is a Public Working Draft whose circulation is unrestricted. Comments should be directed to the editor and/or contributors by e-mail.  Recipients of this draft are invited to submit, with their comments, notification of any relevant patent rights of which they are aware and to provide supporting documentation.
In the final version of this document:
•	relevant schema extracts will be included in the text of the specification
•	relevant examples will be included
•	error codes will be included.
To reduce the editorial burden, these aspects of the specification have been omitted for some working drafts.
Normative status
This document is normative in the sense that any implementing processor must obey the rules described herein, in order to be considered a conformant processor.
Table of contents
Contributors
Typographic conventions
Formatting conventions
Namespace conventions (normative)
1	Introduction
2	Syntax
2.1	XPath usage
2.1.1	Parameters
2.1.2	Custom functions
2.2	Formula resources
2.2.1	Formula results
2.2.2	Concept identifier
2.2.3	Concept-formula relationships
2.2.4	Result context
2.2.5	Result unit
2.2.6	Result accuracy
2.2.7	Result custom attributes
2.3	Formula variables
2.3.1	Formula-variable relationships
2.4	Formula preconditions
2.4.1	Precondition declarations
2.4.2	Formula-precondition relationships
3	Processing model
3.1	Input
3.2	Formula evaluation
3.3	Message reporting by formula processors
3.3.1	Syntactic errors in formula declarations
3.3.2	XPath expression evaluation exceptions
3.3.3	Failed or successful variable bindings
3.3.4	Failed or successful formula bindings
3.3.5	Messages about the content of the target instance
Appendices
A	References (non-normative)
B	Normative error codes
C	Normative schema
D	Intellectual Property Status (non-normative)
E	Acknowledgements (non-normative)
F	Document History (non-normative)
G	Approval process (non-normative)

Document conventions (non-normative)
Typographic conventions
Comments which are informative, but not essential to the understanding of the point at hand are provided in footnotes. All footnotes are non-normative.
Formatting conventions
The following highlighting is used to present normative technical material in this document:
	
The following formatting is used for non-normative examples in this document:

The following formatting is used for non-normative counterexamples (examples of poor, discouraged or disallowed usage) in this document:

Namespace conventions (normative)
This table contains all the prefixes used within the text and the correspondent namespace URI. The prefix column in the table above is non normative. The namespace URI column is normative.
Prefix	Namespace URI	
xbrli	http://www.xbrl.org/2003/instance	
generic	http://xbrl.org/2007/generic	
formula	http://xbrl.org/2007/formula	
Relationship to other work
This specification depends upon XBRL 2.1 Specification [XBRL]. This specification depends upon XBRL Variables 1.0 Specification [VARIABLES].
In the event of any conflicts between this specification and the specifications upon which it depends, this specification does not prevail.
Language independence
The official language of XBRL International’s own work products is English and the preferred spelling convention is UK English.
Terminology
All terminology defined in the XBRL 2.1 Specification and the XBRL Variables 1.0 Specification is used unchanged in this specification.
The following additional terms are used as described in the table below:
Term	Meaning (Normative)	
target instance	The target instance is the XBRL instance containing facts that MAY be bound to variables.	
1	Introduction
A formula is way of describing formulaic relationships between XBRL components, mainly XBRL concepts. When evaluated successfully against an XBRL instance, formulae produce new XBRL facts. For example, a simple formula may express the formulaic relationship of current ratio = current assets / current liabilities. The formula describes the use of the XBRL concepts for the current ratio, current assets and current liabilities and that current assets should be divided by current liabilities to result in a value for the current ratio.
The general processing model for a formula is to apply the formula against an XBRL instance document. Formulae may be used to validate information in the instance document or to produce new facts to augment the information in the instance document.
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 those explanations are not already provided in other specifications.
2.1	XPath usage
Some attributes defined by this specification contain values that are evaluated as XPath 2.0 [XPATH] expressions. Wherever an XPath expression is mentioned in this specification it refers to an XPath 2.0 expression. The evaluation context for an XPath expression is determined by the attribute that contains the expression. The statically known namespaces used in the expressions are those that are in scope for the element that has the attribute that contains the XPath expression.
Evaluation of XPath expressions MUST NOT be performed using the XPath 1.0 compatibility mode.
QNames in each XPath expression MUST be resolvable using namespace declarations that are in scope for the element that contains the XPath expression.  See Namespaces in XML 1.0 [NAMESPACE] for more information on namespace declarations and their scope.
2.1.1	Parameters
Parameters MAY be referenced within XPath expressions.  Any parameters that are referenced by an XPath expression MUST be declared within the same DTS that contains the XPath expression.  Parameters are declared using the formula:parameter element.
A parameter declaration is an XLink resource.
The name attribute on a parameter declaration MUST contain the QName of the parameter being declared.
If the required attribute on a parameter declaration is equal to true, then the parameter is mandatory, meaning that its value MUST be supplied by the caller.
The value of the parameter MAY be supplied by the caller. If no value was supplied by the caller, and if the parameter is not mandatory, then the supplied value MAY be computed using the XPath expression given in the select attribute.
A parameter declaration MAY contain an as attribute that specifies the data type required by the parameter.  If a data type is specified, then it is an error if the parameter value (either supplied by the caller or determined from the select attribute) cannot be converted to the specified data type.
Note: Sequence constructors are not available for declaring the rules for determining default parameter values.
2.1.2	Custom functions
Custom functions MAY be referenced within XPath expressions.  Any custom functions that are referenced by an XPath expression MUST be declared within the same DTS that contains the XPath expression.  Custom functions are declared using the formula:function element.
A custom function declaration is an XLink resource.
The name attribute on a custom function declaration MUST contain the QName of the custom function being declared.
A custom function MUST contain a output attribute that has a value identifying the data type of the result produced by evaluation of the custom function.
A custom function MAY contain child input elements. These elements contain information about the custom function's input parameters. All input elements MUST define a strict parameter ordering using the values of their order attributes.  The type attribute  on input elements MUST contain a value identifying the data type of the input parameter.
2.2	Formula resources
Formulae are declared using the formula:formula element in an XBRL extended link.  Such a declaration is referred to as a formula.
2.2.1	Formula results
The content of a value attribute on formula is interpreted as an XPath expression.  It is referred to as the formula expression.
When evaluated it MUST produce the value of a single XBRL item.
The formula expression MUST be evaluated using the xbrli:xbrl element of the target instance as the context node.
2.2.2	Concept identifier
A formula MAY contain a concept identifier. A concept identifier is the concept attribute on the formula itself.  A concept identifier provides a means of determining the concept to be used for an item produced by the formula.  It is suitable for formulae that produce items for more than one concept.
The content of a concept identifier is the QName of a fact variable. The fact that the fact variable has evaluated to has a concept.  That concept is the concept for the output fact.  It is an error if the identified fact variable has its bindAsSequence attribute set to true.
2.2.3	Concept-formula relationships
Alternatively, the concept, for which a formula can produce items, MAY be identified by a concept-formula relationship.  Such relationships are referred to as concept-formula relationships.  They are expressed using XLink arcs.
To express a concept-formula relationship from a concept to a formula, an XLink arc element MUST:
•	have an arcrole equal to http://xbrl.org/arcrole/2007/concept-formula;
•	have the concept at the source of the arc; and
•	have the formula at the target of the arc.
In a DTS, a formula MUST not have a concept-formula relationship to more than one concept.
A formula MAY have no concept-formula relationships to concepts.  In such cases, the concept MAY produce facts for any concepts. Which concept a fact is produced for by a successful formula evaluation is then determined by the output concept identifier.
It is an error if a formula contains a concept identifier and participates in any concept-formula relationships.
2.2.4	Result context
When evaluated, formulae MAY produce items, which require contexts.  Contexts have many different aspects, such as the entity identifier and the period, all of which need to be determined.
The rules determining the result context are specified in the formula:context child element of a formula resource.
The formula:context element defines the result context in terms of the context of the fact that a specified fact variable has evaluated to.  That fact is referred to as the reference fact and its context is referred to as the reference context.
The fact variable is identified by the QName value of the referenceVariable attribute on the formula:context element.
2.2.4.1	Construction rules for entity identifiers
The formula:context element MAY also have a child formula:identifier element. It provides the rules for constructing the entity identifier in the result context.  
If the formula:identifier element is omitted, then the constructed context MUST have an entity identifier scheme that is s-equal to that of the reference context.
A formula:identifier element may redefine the reference fact and the reference context, within its own scope, using its own referenceVariable attribute.
If the formula:identifier element only contains a referenceVariable attribute then the constructed context MUST have an entity identifier that is s-equal to that of the reference context.
If the formula:identifier element contains a scheme attribute then the constructed context MUST have an entity identifier scheme that is s-equal to that obtained by evaluating the XPath expression contained by the scheme attribute.
If the formula:identifier element contains a value attribute then the constructed context MUST have an entity identifier value that is s-equal to that obtained by evaluating the XPath expression contained by the value attribute.
2.2.4.2	Construction rules for segments
The formula:context element MAY also have a child formula:segment element. It provides the rules for constructing the segment in the result context.
If the formula:segment element is omitted, then the constructed context MUST have a segment that is s-equal to that of the reference context.
A formula:segment element may redefine the reference fact and the reference context, within its own scope, using its own referenceVariable attribute.
If the formula:segment element only contains a referenceVariable attribute then the constructed context MUST have a segment that is s-equal to that of the reference context.
If the formula:segment element contains a value attribute then the constructed context MUST have a segment that is s-equal to that obtained by evaluating the XPath expression contained by the value attribute.
2.2.4.3	Construction rules for periods
The formula:context element MAY also have a child formula:period element. It provides the rules for constructing the period in the result context.
If the formula:period element is omitted, then the constructed context MUST have a period that is s-equal to that of the reference context.
A formula:period element may redefine the reference fact and the reference context, within its own scope, using its own referenceVariable attribute.
If the formula:period element only contains a referenceVariable attribute then the constructed context MUST have a period that is s-equal to that of the reference context.
If the formula:period element contains a formula:forever element then the constructed context MUST have a forever period.
If the formula:period element contains a formula:instant element then the constructed context MUST have an instant period with a value that is s-equal to that obtained by evaluating the XPath expression contained by the value attribute on the formula:instant element.
If the formula:period element contains a formula:duration element then the constructed context MUST:
•	start with a value that is s-equal to that obtained by evaluating the XPath expression contained by the start attribute on the formula:duration element; and
•	end with a value that is s-equal to that obtained by evaluating the XPath expression contained by the end attribute on the formula:duration element.
2.2.4.4	Construction rules for scenarios
The formula:context element MAY also have a child formula:scenario element. It provides the rules for constructing the scenario in the result context.
If the formula:scenario element is omitted, then the constructed context MUST have a scenario that is s-equal to that of the reference context.
A formula:scenario element may redefine the reference fact and the reference context, within its own scope, using its own referenceVariable attribute.
If the formula:scenario element only contains a referenceVariable attribute then the constructed context MUST have a scenario that is s-equal to that of the reference context.
If the formula:scenario element contains a value attribute then the constructed context MUST have a scenario that is s-equal to that obtained by evaluating the XPath expression contained by the value attribute.
2.2.5	Result unit
When evaluated, formulae MAY produce numeric items, which require units.
The rules determining the result unit are specified in the formula:unit child element of a formula resource.
A formula that constructs numeric items MUST include a formula:unit element.
The formula:unit element defines the result unit in terms of the unit of the fact that a specified fact variable has evaluated to.  That fact is referred to as the reference fact and its unit is referred to as the reference unit.  It is an error if the reference fact is non-numeric.
The fact variable is identified by the QName value of the referenceVariable attribute on the formula:unit element.
The formula:unit element MAY contain any number of formula:multiplyBy and formula:divideBy elements.
Each formula:multiplyBy element defines a collection of one or more numerator measures and a collection of zero or more denominator measures. Likewise, each formula:divideBy element defines a collection of one or more numerator measures and a collection of zero or more denominator measures.
If the formula:unit element contains no child elements, then the constructed unit MUST be u-equal to that of the reference unit.
formula:multiplyBy elements and formula:divideBy elements may redefine the reference fact and the reference unit, within their own scope, using their own referenceVariable attribute.
If a formula:multiplyBy element or a formula:divideBy element contains no measure attribute, then its collection of numerator measures is the collection of measures in the numerator of the reference unit and its collection of denominator measures is the collection of measures in the denominator of the reference unit.
Otherwise, a formula:multiplyBy element or a formula:divideBy element has a singleton collection of numerator measures and an empty collection of denominator measures. The single numerator measure is determined by the QName resulting from evaluation of the XPath expression contained by the measure attribute.
If the formula:unit element contains child elements, then the result unit MUST be obtained by the following process:
1.	Combine the collections of numerator measures for the children formula:multiplyBy elements with the collections of denominator measures for the children formula:divideBy elements to obtain a single numerator collection of measures.
2.	Combine the collections of denominator measures for the children formula:multiplyBy elements with the collections of numerator measures for the children formula:divideBy elements to obtain a single denominator collection of measures.
3.	Cancel out any measures that appear in both the numerator collection and the denominator collection
The result unit MUST have a measure in its numerator for each measure in the single numerator collection, after performing the cancellation operation.  The result unit MUST have a measure in its denominator for each measure in the single denominator collection, after performing the cancellation operation.
2.2.6	Result accuracy
If a formula generates numeric values and the formula contains a formula:precision child element, a value for the precision attribute on the result fact MAY be obtained by evaluating the XPath expression given in the value attribute of the formula:precision element.
If a formula generates numeric values and the formula contains a formula:decimals child element, a value for the decimals attribute on the result fact MAY be obtained by evaluating the XPath expression given in the value attribute of the formula:decimals element.
If a formula generates a numeric value and the formula does not contain a formula:precision child element or a formula:decimals child element, then the result fact MUST be reported with zero precision.
Determination of whether a fact generated by a formula is reported using the precision or decimals attribute is not within the scope of this specification.
2.2.7	Result custom attributes
A formula:attribute child element of a formula specifies a value for a custom attribute that MUST be added to any items produced as a result of evaluating the formula.
The namespace of the custom attribute is specified by the value of the namespace attribute on the formula:attribute element.
The namespace prefix to use for the custom attribute is specified by the value of the prefix attribute on the formula:attribute element.
The local name of the custom attribute is specified by the value of the name attribute on the formula:attribute element.
The value attribute is interpreted as an XPath expression.  The value of the custom attribute is determined by evaluation of the value attribute on the formula:attribute element.
2.3	Formula variables
XPath expressions in a formula declaration MAY include references to XPath variables. These variables are resolved to fact variables or to general variables that are related to formulae by formula-variable relationships.
2.3.1	Formula-variable relationships
Formula-variable relationships are expressed using XLink arcs [XLink].  To declare a formula-variable relationship between a formula and a variable, an XLink arc element MUST:
•	be a formula:arc;
•	have an arcrole equal to http://xbrl.org/arcrole/2007/formula-variable;
•	have the formula at the source of the arc; and
•	have either a fact variable or a general variable at the target of the arc.
The value of the name attribute on a formula-variable arc is the QName of the variables defined by the relationships that the arc expresses. This QName MUST be used when referencing the variable from XPath expressions.
2.4	Formula preconditions
Formulae MAY be associated with preconditions that declare conditions under which the formula is to be evaluated.
2.4.1	Precondition declarations
A precondition is declared by a formula:precondition element. A precondition specifies the conditions that MUST be determined to be satisfied before a formula is evaluated.
The test attribute on a precondition is interpreted as an XPath expression.  It's content is referred to as a precondition expression.  A precondition is satisfied if the precondition expression evaluates to an XPath effective Boolean value of true.
2.4.2	Formula-precondition relationships
The preconditions for evaluating a formula are identified by formula-precondition relationships. Such relationships are expressed using XLink arcs.  To express a formula-precondition relationship between a formula and a precondition, an XLink arc element MUST:
•	have an arcrole equal to http://xbrl.org/arcrole/2007/formula-precondition;
•	have the formula at the source of the arc; and
•	have the precondition at the target of the arc.
3	Processing model
This section defines the processing model for a formula.  The processing model is only defined for a single evaluation of a single formula.  Given a target XBRL instance, it MAY be possible to evaluate a formula against several different sets of the facts contained by that XBRL instance.
3.1	Input
The input to a formula processor is an XBRL instance, referred to as the target instance.
3.2	Formula evaluation
A formula evaluation entails:
•	First. evaluating each of the formula's parameters and variables;
•	Second, evaluating the formula's preconditions to ensure that they are satisfied; and
•	Third, evaluating the formula expression if all variables can be evaluated and all preconditions are satisfied.
A formula MUST evaluate parameters and variables using the evaluation order indicated by the order attribute on the XLink arcs defining the formula's variables and parameters.
To support this ordering analysis, there MUST be a strict ordering of relationships from the formula to each of its variables and parameters.
The comparison fact variable to use when evaluating each fact variable is the preceding fact variable, in evaluation order, with its bindAsSequence attribute set to false.  If the fact variable being evaluated has no preceding fact variable, in evaluation order, with its bindAsSequence attribute set to false, then it has no comparison fact variable.  The role of the comparison fact variable is defined in the Variables 1.0 Specification [VARIABLES].
An XPath expression has a variable dependency if the expression includes an XPath variable.  An XPath expression cannot be evaluated if it has unresolved variable dependencies.
A variable dependency for an XPath variable is resolved only if a variable with the same QName as the XPath variable being resolved has already been evaluated as part of the formula evaluation.
If a formula can be evaluated to produce an item value, the XPath expressions determining the concept, context, unit and precision of that item MAY also be evaluated.
3.3	Message reporting by formula processors
A broad range of information can be usefully provided by a formula processor.
Such information includes:
1.	Syntactic errors in formula declarations
2.	XPath expression evaluation exceptions
3.	Failed or successful variable bindings
4.	Failed or successful formula bindings
5.	Messages about the content of the target instance
The handling for each of these kinds of messages is addressed below.
3.3.1	Syntactic errors in formula declarations
Syntactic errors in formula declarations are violations of this specification.  Such violations of this specification MUST be reported by a formula processor using the error codes defined in this specification.  See Appendix B.
3.3.2	XPath expression evaluation exceptions
XPath evaluation exceptions MAY be reported by formula processors.  This specification imposes no constraints on the reporting method.
3.3.3	Failed or successful variable bindings
Failed or successful variable bindings MAY be reported by formula processors.  This specification imposes no constraints on the reporting method.
3.3.4	Failed or successful formula bindings
Failed or successful formula bindings MAY be reported by formula processors.  This specification imposes no constraints on the reporting method.
3.3.5	Messages about the content of the target instance
The rules for creation of messages about the content of the target instance MAY be structured as formulae.  If this approach is adopted, then messages about the content of the target instance will be available from a formula processor as XBRL facts.
Appendices
A	References (non-normative)

[GENLINK]	Mark Goodhand, Ignacio Hernández-Ros, Geoff Shuetrim (editors)
XBRL Generic Links 1.0, Public Working Draft
http://www.xbrl.org/SpecPWDs/ 	
[NAMESPACE]	Tim Bray, Dave Hollander, Andrew Layman, Richard Tobin
Namespaces in XML 1.0 (Second Edition)
http://www.w3.org/TR/REC-xml-names/
	
[VARIABLES]	Phillip Engel, Geoff Shuetrim, David vun Kannon, Hugh Wallis (editors)
XBRL Variables 1.0 Specification, Public Working Draft
http://www.xbrl.org/SpecPWDs/	
[XBRL]	Phillip Engel, Walter Hamscher, Geoff Shuetrim, David vun Kannon and Hugh Wallis
Extensible Business Reporting Language 2.1 Recommendation 
http://www.xbrl.org/SpecRecommendations/ 
	
[XLink]	Steve DeRose, Eve Maler, and David Orchard
XML Linking Language (XLink) Version 1.0
http://www.w3.org/TR/xlink
	
[XPATH]	Scott Boag, Don Chamberlin, Mary F. Fernández, Michael Kay, Johnathan Robie, Jérôme Siméon
XML Path Language (XPath) 2.0
http://www.w3.org/TR/xpath20

B	Normative error codes
Normative error codes defined in this specification are listed here.
To be completed.
C	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/2007/ - 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/2007/formula.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. 

<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2007 XBRL International. All Rights Reserved. -->
<schema 
  xmlns="http://www.w3.org/2001/XMLSchema" 
  targetNamespace="http://xbrl.org/2007/formula"
  xmlns:formula="http://xbrl.org/2007/formula"
  xmlns:expression="http://xbrl.org/2007/expression" 
  xmlns:generic="http://xbrl.org/2007/generic" 
  xmlns:link="http://www.xbrl.org/2003/linkbase" 
  xmlns:xl="http://www.xbrl.org/2003/XLink"
  elementFormDefault="qualified"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="
  http://www.w3.org/2001/XMLSchema http://www.w3.org/2001/XMLSchema.xsd
  http://www.xbrl.org/2003/linkbase http://www.xbrl.org/2003/xbrl-linkbase-2003-12-31.xsd
  ">

  <import namespace="http://www.xbrl.org/2003/XLink" 
    schemaLocation="http://www.xbrl.org/2003/xl-2003-12-31.xsd"/>

  <import namespace="http://xbrl.org/2007/expression" 
    schemaLocation="expression.xsd"/>

  <element name="formula" substitutionGroup="xl:resource">
    <complexType mixed="true">
      <complexContent mixed="true">
        <extension base="xl:resourceType">
          <sequence minOccurs="0">
            <element name="context"  minOccurs="0">
              <complexType>
                <sequence minOccurs="0">
                  <element name="identifier" minOccurs="0">
                    <complexType>
                      <attribute name="referenceVariable" type="QName" use="optional"/>
                      <attribute name="scheme" type="expression:expression" use="optional" />
                      <attribute name="value" type="expression:expression" use="optional" />
                    </complexType>
                  </element>
                  <element name="segment" minOccurs="0">
                    <complexType>
                      <attribute name="referenceVariable" type="QName" use="optional"/>
                      <attribute name="value" type="expression:expression" use="optional" />
                    </complexType>
                  </element>
                  <element name="period" minOccurs="0">
                    <complexType>
                      <choice>
                        <element name="forever">
                          <complexType/>
                        </element>
                        <element name="instant">
                          <complexType>
                            <attribute name="value" type="expression:expression" use="optional" />
                          </complexType>
                        </element>
                        <element name="duration">
                          <complexType>
                            <attribute name="start" type="expression:expression" use="optional" />
                            <attribute name="end" type="expression:expression" use="optional" />
                          </complexType>
                        </element>
                      </choice>
                      <attribute name="referenceVariable" type="QName" use="optional"/>
                    </complexType>
                  </element>        
                  <element name="scenario" minOccurs="0">
                    <complexType>
                      <attribute name="referenceVariable" type="QName" use="optional"/>
                      <attribute name="value" type="expression:expression" use="optional" />
                    </complexType>
                  </element>
                </sequence>
                <attribute name="referenceVariable" type="QName" use="required"/>
              </complexType>
            </element>
            <element name="unit" minOccurs="0">
              <complexType>
                <sequence>
                  <element name="multiplyBy" minOccurs="0" maxOccurs="unbounded">
                    <complexType>
                      <attribute name="measure" type="expression:expression" use="optional" />            
                      <attribute name="referenceVariable" type="QName" use="optional"/>
                    </complexType>
                  </element>
                  <element name="divideBy" minOccurs="0" maxOccurs="unbounded">
                    <complexType>
                      <attribute name="measure" type="expression:expression" use="optional" />            
                      <attribute name="referenceVariable" type="QName" use="optional"/>
                    </complexType>
                  </element>
                </sequence>
                <attribute name="referenceVariable" type="QName" use="required"/>
              </complexType>
            </element>
            <choice minOccurs="0">
              <element name="precision" type="expression:expression" />
              <element name="decimals" type="expression:expression" />
            </choice>
            <element name="attribute" minOccurs="0">
              <complexType>
                <attribute name="id" type="ID" use="optional"/>
                <attribute name="namespace" type="anyURI" use="required"/>
                <attribute name="prefix" type="NCName" use="required"/>
                <attribute name="name" type="NCName" use="required"/>
                <attribute name="value" type="expression:expression" use="required"/>
              </complexType>
            </element>
          </sequence>
          <attribute name="value" type="expression:expression" use="required"/>
          <attribute name="concept" type="QName" use="optional"/>
          <anyAttribute namespace="http://www.w3.org/XML/1998/namespace" processContents="lax"/>
        </extension>
      </complexContent>
    </complexType>
  </element>

  <element name="arc" substitutionGroup="xl:arc">
    <complexType>
      <complexContent>
        <extension base="xl:arcType">
          <attribute name="bindEmpty" type="boolean" use="required"/>
          <attribute name="bindAsSequence" type="boolean" use="required"/>
          <attribute name="name" type="QName" use="required"/>
        </extension>
      </complexContent>
    </complexType>
  </element>

  <element name="parameter" substitutionGroup="xl:resource">
    <complexType mixed="true">
      <complexContent mixed="true">
        <extension base="xl:resourceType">
          <attribute name="name" type="QName" use="required"/>
          <attribute name="select" type="expression:expression" use="optional"/>
          <attribute name="required" use="optional">
            <simpleType>
              <restriction base="string">
                <enumeration value="yes"/>
                <enumeration value="no"/>
              </restriction>
            </simpleType>
          </attribute>
          <attribute name="as" type="QName" use="optional"/>
          <anyAttribute namespace="http://www.w3.org/XML/1998/namespace" processContents="lax"/>
        </extension>
      </complexContent>
    </complexType>
  </element>

  <element name="function" substitutionGroup="xl:resource">
    <complexType mixed="true">
      <complexContent mixed="true">
        <extension base="xl:resourceType">
          <sequence minOccurs="0" maxOccurs="unbounded">
            <element name="input">
              <complexType>
                <attribute name="type" type="QName" use="required"/>
                <attribute name="order" type="integer" use="required"/>
              </complexType>
            </element>
          </sequence>
          <attribute name="name" type="QName" use="required"/>
          <attribute name="output" type="QName" use="required"/>
          <anyAttribute namespace="http://www.w3.org/XML/1998/namespace" 
            processContents="lax"/>
        </extension>
      </complexContent>
    </complexType>
  </element>

  <element name="precondition" substitutionGroup="xl:resource">
    <complexType mixed="true">
      <complexContent mixed="true">
        <extension base="xl:resourceType">
          <attribute name="test" 
            type="expression:expression" use="required" />
        </extension>
      </complexContent>
    </complexType>
  </element>

</schema>	
D	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).
E	Acknowledgements (non-normative)
This document could not have been written without the contributions of many people including the participants in the XBRL Formula Working Group.
F	Document History (non-normative)
Date	Editor	Summary	
2006-12-18	Geoff Shuetrim	First internal working draft created, drawing extensively on the previous Formula specification drafts.	
2007-04-23	Geoff Shuetrim	Added text to the formula processing model to clarify that a formula may be evaluated against an XBRL instance to produce more than one output fact.
Changed the concept-formula relationship from a formula arc to a generic arc.	
2007-04-24	Geoff Shuetrim	Amended the processing model to move the bindAsSequence material to the variables specification and to introduce the material on comparison fact variables referencing the fact variable evaluation specification in the variables specification.  This injects implicit filtering capabilities into formula evaluation.	
2007-04-25	Geoff Shuetrim	Added a date to the arcroles defined in the specification.
Added XPath expression parameter declaration syntax.
Added XPath custom function declaration syntax.	
2007-05-02	Geoff Shuetrim	Changed the unit and context construction rules and the accuracy construction rules to make greater use of references to fact variables.	
2007-05-07	Geoff Shuetrim	Removed the requirement that relationships be defined in terms of the concrete arcs that express them.	
2007-05-08	Geoff Shuetrim	Fixed the XPath reference to refer to the recommendation rather than a working draft.	
2007-05-29	Geoff Shuetrim	Changed references to decimal to decimals to be consistent with the XBRL 2.1 specification.	
2007-06-11	Geoff Shuetrim	Added a validation error to cover situations where a formula contains a concept attribute and has formula-concept relationships.  Moved the section on concept-formula relationships to be adjacent to the concept identifier section.  Reverted to an explicit ordering of evaluation for variables (and parameters) given the complex nature of the interaction between implicit orderings and implicit filtering.	
2007-07-24	Hugh Wallis	Editorial for publication	
G	Approval process (non-normative)
This section will be removed from the final recommendation.
This specification is being developed following the XBRL Technical Working Group Processes: http://www.xbrl.org/XSB/XBRL_Technical_Working_Group_Processes-Approved-2007-04-17.htm