XBRL Functions 1.0
Public Working Draft of 2006-12-07
Copyright © 2005, 2006, XBRL International Inc., All Rights Reserved
This file:
XF-PWD-2006-12-07.rtf 
is Normative. All other versions and formats are non-normative.
Editors
Name	e-mail	Affiliation	
Chris Simmons	cps@decisionsoft.com	DecisionSoft	
Ignacio Hernández-Ros	ihr@xbrl.org	XBRL International Inc.	
Contributors
Cliff Binstock	cliff.binstock@coyotereporting.com	Coyote Reporting LLC	
Phillip Engel	phillip.engel@morganstanley.com 	Morgan Stanley	
Herm Fischer	fischer@markv.com	UBmatrix	
David vun Kannon	david.k.vunkannon@us.pwc.com	PricewaterhouseCoopers	
Hugh Wallis	hughwallis@xbrl.org	XBRL International Inc.	
Paul Warren	pdw@decisionsoft.com	DecisionSoft	
Status of this document
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.  
Abstract
This specification builds on the eXtensible Business Reporting Language (XBRL) version 2.1 specification. It defines XPath 2.0 functions to aid in the querying and creation of XBRL instance documents, effectively providing an XBRL specific extension to XPath 2.0.
Table of contents
Editors
Contributors
Status of this document
Abstract
Table of contents
Introduction
Terminology and formatting conventions
Normative status
Language independence
Namespace bindings
Examples
Accessor Functions
Item types
is-numeric
Decimals and precision
precision
Contexts and units
context
unit
Units
unit-numerator
unit-denominator
measure-name
Contexts
Periods
period
context-period
is-start-end-period
is-forever-period
is-duration-period
is-instant-period
period-start
period-end
period-instant
Segments and Entities
entity
context-entity
identifier
context-identifier
entity-identifier
identifier-value
identifier-scheme
segment
entity-segment
context-segment
scenario
context-scenario
Facts and tuples
items-in-instance
tuples-in-instance
items-in-tuple
tuples-in-tuple
Predicates
identical-nodes
s-equal
u-equal
v-equal
c-equal
identical-node-set
s-equal-set
v-equal-set
c-equal-set
u-equal-set
x-equal
duplicate-item
duplicate-tuple
p-equal
cu-equal
pc-equal
pcu-equal
Constructor Functions
Creating items
create-numeric-item-precision
create-numeric-item-decimals
create-non-numeric-item
create-nil-item
Creating tuples
create-tuple 
Creating contexts
Periods
create-period
create-period
create-period
Entity, Segments and Scenario Constructors
create-entity
Context Constructors
create-context
create-start-instant-context
create-end-instant-context
create-context-from-instant-contexts
Unit Constructors
create-unit
create-product-unit
create-inverse-unit
Creating instances
create-schemaRef
create-linkbaseRef
create-instance 
Creating footnotes
create-footnoteLink
create-footnote
create-loc
create-footnoteArc
Errors
Document history (non-normative)
Intellectual Property Status (non-normative)
References (non-normative)
Appendix: Approval process (non-normative)

Introduction
This specification sets out a collection of functions which operate on XBRL constructs and defines their expected behaviour. These functions act upon the schema types of XBRL, using the notation set out in the XPath and XQuery.
See http://www.w3.org/TR/xquery-semantics/#sec_content_models for details on the type system used herein and http://www.w3.org/TR/xquery-operators/#func-signatures for the notation used for specifying function signatures.
Terminology and formatting conventions
Terminology used in XBRL frequently overlaps with terminology from other fields.  The terminology used in this document is summarised below.
Table 1.   Terminology
Abstract element, bind, concept, concrete element, context, Discoverable Taxonomy Set (DTS), duplicate items, duplicate tuples, element, entity, equal, essence concept, fact, instance, item, least common ancestor, linkbase, period, taxonomy, tuple, unit, taxonomy schema, child, parent, sibling, grandparent, uncle, ancestor, XBRL instance, c-equal, p-equal, s-equal, u-equal, v-equal, x-equal, minimally conforming XBRL processor, fully conforming XBRL processor.	As defined in [XBRL].	
must, must not, required, shall, shall not, should, should not, may, optional	See [RFC2119] for definitions of these and other terms.  These include, in particular:
should
Conforming documents and applications are encouraged to behave as described.
must
Conforming documents and consuming applications are required to behave as described; otherwise they are in error.	
Binding language	An implementation of the functions will be available in a particular programming language.  This is the binding language.	
Implementation language	The implementation language is the language in which the behaviour of the functions is implemented.  This will often be the same as the binding language but this is not necessarily the case.  Notably, XPath 2 functions are typically implemented in another language.	
The following highlighting is used for positive examples:
Example 1.  Example of an example
	
Counterexamples indicate incorrect or unsupported examples:
Example 2.  Example of a counterexample
	
Selections from other normative documents is highlighted thus:
Example 3.  Example of normative material
	
Non-normative editorial comments are denoted as follows and removed from final recommendations:
CPS: This highlighting indicates editorial comments about the current draft, prefixed by the editor’s initials.
Italics are used for rhetorical emphasis only and do not convey any special normative meaning.
Normative status
This document is normative in the sense that any function specification recommendations by XBRL International must satisfy the requirements as they are stated here. 
This document version depends upon XBRL 2.1 Specification Recommendation.
XBRL Specification 2.1 does not depend in any way upon this document.
Language independence
The official language of XBRL International’s own work products is English and the preferred spelling convention is UK English.  
Namespace bindings
All bindings defined in this specification are defined in the namespace "http://www.xbrl.org/2005/function/instance". Certain namespace prefix bindings are used throughout this specification, although their use is non-normative. 
Prefix	Namespace	
xfi 	 http://www.xbrl.org/2005/function/instance 	
xfie 	 http://www.xbrl.org/2005/function/instance/error 	
xbrli 	 http://www.xbrl.org/2003/instance 	
link 	 http://www.xbrl.org/2003/linkbase 	
xl 	 http://www.xbrl.org/2003/XLink	
iso4217	 http://www.xbrl.org/2003/iso4217	
xs 	 http://www.w3.org/2001/XMLSchema 	
fn 	 http://www.w3.org/2004/10/xpath-functions 	
xdt 	 http://www.w3.org/2004/10/xpath-datatypes 	
err 	 http://www.w3.org/2004/10/xqt-errors 	
The reference implementation of the functions described in this document can be found in the following URL:
http://www.xbrl.org/2006/functions/xf-2006.xq
Software vendors are free to use that set of functions from the web or in a local copy of that file and to provide custom implementation of that functions. The custom version of those functions MUST produce exactly the same output as the reference functions. The functions are implemented using the W3C XQuery [XQuery] language.
Examples
This specification contains examples for the use and expected outcome of applying the functions to various XBRL instances. All instances occur in the examples directory use the same simple taxonomy. 
The following variables are used in examples, and refer to various elements in the given example instance document. In addition to the namespace bindings defined earlier, we define the following namespace binding for use in examples. 
Prefix	Namespace	
acme	 http://example.com/acme/results/2003-07-01	

Example 4.  Variables used in examples

Variable	XPath expression	
$acme-instance	doc("examples/acme-results.xbrl")/xbrli:xbrl	
$duplicates-instance	doc("examples/duplicates.xbrl")/xbrli:xbrl	
$acme-taxonomy	doc("examples/taxonomy/acme.xsd")/xs:schema	
$acme-taxonomy-small	doc("examples/taxonomy/acme-small.xsd")/xs:schema	
$acme-linkbase-pres	doc("examples/taxonomy/acme_presentation.xml")/link:linkbase/link:presentationLink	
$u1	$acme-instance/id("u1")	
$u2	$acme-instance/id("u2")	
$u4	$acme-instance/id("u4")	
$c1	$acme-instance/id("c1")	
$c2	$acme-instance/id("c2")	
$c3	$acme-instance/id("c3")	
$c1UK	$acme-instance/id("c1UK")	
$c1US	$acme-instance/id("c1US")	
$c1Asia	$acme-instance/id("c1Asia")	
$totalRevenue1	$acme-instance/acme:totalRevenue[1]	
$totalRevenue2	$acme-instance/acme:totalRevenue[2]	
$totalExpenditure	$acme-instance/acme:totalExpenditure	
$revenueByGeographicSegmentUS	$acme-instance/acme:revenueByGeographicSegment[@contextRef="c1US"]	
$title	$acme-instance/acme:additionalInformation/acme:title	
$duplicateItem	$duplicates-instance/acme:totalRevenue[1]	
$duplicateTuple	$duplicates-instance/acme:companyWebsite[1]	
Accessor Functions
Many functions are defined for accessing the various components of an XBRL instance. Their distinguishing feature is that they supply access to the various components of an XBRL instance, in a fashion that exposes their relationships.
For each standard ‘dimension’ of an item (namely the unit, period, identifier, segment and scenario), there is a corresponding function to access that dimension directly from the item.  Additional functions are defined to access components from other starting points.
Item types
Items come in two distinct types, numeric and non-numeric, and it is often necessary to distinguish between them.  In particular, numeric items have units and precision or decimals.  Certain functions specified in this document are only defined for items that are numeric and will raise the error xfie:ItemIsNotNumeric should they be applied to non-numeric items.
is-numeric
xfi:is-numeric($item as schema-element(xbrli:item)) as xs:boolean
Parameters
$item 	The item to test.	
Returns true if the item is of or is derived from one of the following types and false otherwise.
•	xbrli:fractionItemType
•	xbrli:decimalItemType 
•	xbrli:floatItemType 
•	xbrli:doubleItemType 
•	xbrli:monetaryItemType 
•	xbrli:sharesItemType 
•	xbrli:pureItemType 
•	xbrli:integerItemType 
•	xbrli:nonPositiveIntegerItemType 
•	xbrli:negativeIntegerItemType 
•	xbrli:longItemType 
•	xbrli:intItemType 
•	xbrli:shortItemType 
•	xbrli:byteItemType 
•	xbrli:nonNegativeIntegerItemType 
•	xbrli:unsignedLongItemType 
•	xbrli:unsignedIntItemType 
•	xbrli:unsignedShortItemType 
•	xbrli:unsignedByteItemType 
•	xbrli:positiveIntegerItemType
Examples
xfi:is-numeric($totalRevenue1) returns xs:boolean("true")
xfi:is-numeric($title) returns xs:boolean("false")
Decimals and precision
In the XBRL specification, Section 4.6.6, a means of inferring the precision of a fact is defined. On the basis of this, we define a precision function. 
precision 
xfi:precision($item as schema-element(xbrli:item)) as xdt:anyAtomicType
Parameters
$item 	The item for which to obtain the precision.	
Return the actual or the inferred precision of a numeric fact.
For non‑numeric facts, the dynamic error xfie:ItemIsNotNumeric occurs.
Examples
xfi:precision($totalRevenue1) returns xs:string("INF")
xfi:precision($totalRevenue2) returns xs:nonNegativeInteger("9")
Contexts and units
For items, the contextRef attribute references the context of a fact and for numeric items, the unitRef attribute references the unit of a fact. Consequently, we define the following functions: 
context 
xfi:context($item as schema-element(xbrli:item)) as element(xbrli:context)
Parameters
$item 	The item for which to obtain the context.	
Return the context whose id attribute value is equal to the item’s contextRef attribute value.
Examples
xfi:context($totalRevenue1) returns $c1
xfi:context($totalRevenue2) returns $c3
unit 
xfi:unit($item as schema-element(xbrli:item)) as element(xbrli:unit)?
Parameters
$item 	The item for which to obtain the unit.	
Returns the unit whose id attribute value is equal to the item’s unitRef attribute value.  For non-numeric items the empty sequence is returned.
Examples
xfi:unit($totalRevenue1) returns $u1
xfi:unit($totalRevenue2) returns $u2
xfi:unit($title) returns ()
Units
To provide convenient access to the numerator and denominator of a unit, the following functions are provided: 
unit-numerator 
xfi:unit-numerator($unit as element(xbrli:unit)) as element(xbrli:measure)+
Parameters
$item 	The unit for which to obtain the numerator.	
Returns either the measure elements that occur as children of the unitNumerator descendant of the unit in the case where a divide element occurs; otherwise returns the measure children of the unit.
Examples
xfi:unit-numerator($u1) returns the measure iso4217:GBP
xfi:unit-numerator($u4) returns the measure iso4217:USD
unit-denominator 
xfi:unit-denominator($unit as element(xbrli:unit)) as element(xbrli:measure)*
Parameters
$item 	The unit for which to obtain the denominator.	
Returns either the measure elements that occur as children of the unitDenominator descendant of the unit in the case where a divide element occurs; otherwise returns an empty list.
Examples
xfi:unit-denominator($u1) returns ()
xfi:unit-denominator($u4) returns the measure iso4217:GBP
measure-name 
xfi:measure-name($measure as element(xbrli:measure)) as xs:QName
Parameters
$measure 	The measure for which to obtain the qualified name.	
Returns the qualified name specified by the measure.
Examples
xfi:measure-name(xfi:unit-numerator($u1)) returns the QName iso4217:GBP
Contexts
Contexts are containers for periods, segments and scenarios.  Functions are provided for accessing and interrogating the components of contexts.
Periods
period 
xfi:period($item as schema-element(xbrli:item)) as element(xbrli:period)
Parameters
$item	The item.	
Return the period element of the context matching the supplied item’s contextRef attribute.
Examples
xfi:period($totalRevenue1) returns $c1/xbrli:period[1]
context-period 
xfi:context-period($context as element(xbrli:context)) as element(xbrli:period)
Parameters
$context 	 The context.	
Return the period element of the supplied context.
Examples
xfi:context-period($c1) returns $c1/xbrli:period[1]
is-start-end-period 
xfi:is-start-end-period($period as element(xbrli:period)) as xs:boolean
Parameters
$period 	The period.	
Return true if the period contains a startDate and endDate style period and false otherwise.
Examples
xfi:is-start-end-period(xfi:context-period($c1)) returns xs:boolean("true")
xfi:is-start-end-period(xfi:context-period($c2)) returns xs:boolean("false")
is-forever-period 
xfi:is-forever-period($period as element(xbrli:period)) as xs:boolean
Parameters
$period 	The period.	
Returns true if the period contains a forever element, and returns false otherwise.
Examples
xfi:is-forever-period(xfi:context-period($c1)) returns xs:boolean("false")
xfi:is-forever-period(xfi:context-period($c3)) returns xs:boolean("true")
is-duration-period 
xfi:is-duration-period($period as element(xbrli:period)) as xs:boolean
Parameters
$period 	The period.	
Returns true if the period is a duration period (start/end or forever).
Examples
xfi:is-duration-period(xfi:context-period($c1)) returns xs:boolean("true")
xfi:is-duration-period(xfi:context-period($c2)) returns xs:boolean("false")

is-instant-period 
xfi:is-instant-period($period as element(xbrli:period)) as xs:boolean
Parameters
$period	The period.	
Returns true if the period is an instant period.
Examples
xfi:is-instant-period(xfi:context-period($c1)) returns xs:boolean("false")
xfi:is-instant-period(xfi:context-period($c2)) returns xs:boolean("true")
period-start 
xfi:period-start($period as element(xbrli:period)) as xs:dateTime
For the dates, XBRL uses a union of date and dateTime. When a date is specified, it should be expanded to a dateTime as specified in Section 4.7.2 of the XBRL specification.  Note that this expansion differs for beginning and period ends.
Parameters
$period 	The period.	
Return The period start dateTime for start-end periods (satisfying xfi:is-start-end-period($period) ), the instant for instants (satisfying xfi:is-instant-period($period) ), or xfie:PeriodIsForever is raised (if xfi:is-forever-period($period)).
Examples
xfi:period-start(xfi:context-period($c1)) returns xs:dateTime("2004‑03‑31T00:00:00")
xfi:period-start(xfi:context-period($c2)) returns xs:dateTime("2004‑11‑18T00:00:00")
xfi:period-start(xfi:context-period($c3)) raises error xfie:PeriodIsForever
period-end 
xfi:period-end($period as element(xbrli:period)) as xs:dateTime
Parameters
$period	The period	
Return the period end dateTime for start-end periods, the instant for instants, and the dynamic error xfie:PeriodIsForever for forever periods. If the value in the instance is just an xs:date (so not an xs:dateTime) the returning value is augmented in one day to represent the last instant of that period.
Examples
xfi:period-end(xfi:context-period($c1)) returns xs:dateTime("2005‑03‑31T00:00:00")
xfi:period-end(xfi:context-period($c2)) returns xs:dateTime("2004‑11‑19T00:00:00")
xfi:period-end(xfi:context-period($c3)) raises error xfie:PeriodIsForever 
period-instant 
xfi:period-instant($period as element(xbrli:period)) as xs:dateTime
Parameters
$period	The period,	
Returns the period instant date-time or the dynamic error xfie:PeriodIsNotInstant is raised if period is not instant.
Examples
xfi:period-instant(xfi:context-period($c1)) raises error xfie:PeriodIsNotInstant
xfi:period-instant(xfi:context-period($c2)) returns xs:dateTime("2004-11-19T00:00:00")
xfi:period-instant(xfi:context-period($c3)) raises error xfie:PeriodIsNotInstant 
Segments and Entities
entity 
xfi:entity($item as schema-element(xbrli:item)) as element(xbrli:entity)
Parameters
$item 	The item.	
Returns the entity of the context of the given item.
Examples
xfi:entity($totalRevenue1) returns $c1/xbrli:entity
context-entity 
xfi:context-entity($context as element(xbrli:context)) as element(xbrli:entity)
Parameters
$context	The context.	
Returns the entity of the context.
Examples
xfi:context-entity($c1Asia) returns $c1Asia/xbrli:entity
identifier 
xfi:identifier($item as schema-element(xbrli:item)) as element(xbrli:identifier)
Parameters
$item	The item.	
Returns the identifier element associated with the given item.
Examples
xfi:identifier($totalRevenue1) returns $c1/xbrli:entity/xbrli:identifier
context-identifier 
xfi:context-identifier($context as element(xbrli:context)) as element(xbrli:identifier)
Parameters
$context	The context.	
Returns the identifier element associated with the given context.
Examples
xfi:context-identifier($c1) returns $c1/xbrli:entity/xbrli:identifier
entity-identifier 
xfi:entity-identifier($entity as element(xbrli:entity)) as element(xbrli:identifier)
Parameters
$entity	The entity.	
Returns the identifier element associated with the given entity.
Examples
xfi:entity-identifier($c1/xbrli:entity) returns $c1/xbrli:entity/xbrli:identifier

identifier-value 
xfi:identifier-value($identifier as element(xbrli:identifier)) as xs:token
Parameters
$identifier	The identifier.	
Returns the value of the identifier token.
Examples
xfi:identifier-value($c1Asia/xbrli:entity/xbrli:identifier) returns xs:token("Acme")
identifier-scheme 
xfi:identifier-scheme($identifier as element(xbrli:identifier)) as xs:anyURI
Parameters
$identifier	The identifier.	
Return the value of the scheme attribute of the identifier of the entity.
Examples
xfi:identifier-scheme($c1Asia/xbrli:entity/xbrli:identifier) returns xs:anyURI("http://example.com/acme/results")
segment 
xfi:segment($item as schema-element(xbrli:item)) as element(xbrli:segment)?
Parameters
$item 	The item.	
Return the segment of the given item if present and an empty sequence otherwise.
Examples
xfi:segment($revenueByGeographicSegmentUS) returns $c1US/xbrli:entity/xbrli:segment
entity-segment 
xfi:entity-segment($entity as element(xbrli:entity)) as element(xbrli:segment)?
Parameters
$entity 	The entity containing the segment.	
Return the segment content of the given entity if present and an empty sequence otherwise.
Examples
xfi:entity-segment($c1Asia/xbrli:entity) returns ""$c1Asia/xbrli:entity/xbrli:segment
context-segment 
xfi:context-segment($context as element(xbrli:context)) as element(xbrli:segment)?
Parameters
$context 	The context.	
Return the segment content of the given context if present and an empty sequence otherwise.
Examples
xfi:context-segment($c1Asia) returns $c1Asia/xbrli:entity/xbrli:segment
scenario 
xfi:scenario($item as schema-element(xbrli:item)) as element(xbrli:scenario)?

Parameters
$item 	The item.	
Return the scenario of the given item if present and an empty sequence otherwise.
Examples
xfi:scenario($totalRevenue2) returns $c3/xbrli:scenario
context-scenario 
xfi:context-scenario($context as element(xbrli:context)) as element(xbrli:scenario)?
Parameters
$context 	The context.	
Return the scenario content of the given context if present and an empty sequence otherwise.
Examples
xfi:context-scenario($c3) returns $c3/xbrli:scenario
Facts and tuples
items-in-instance
xfi:items-in-instance($instance as element(xbrli:xbrl)) as schema-element(xbrli:item)*
Parameters
$instance	Instance document	
Return a sequence of facts that are direct children of the main xbrli:xbrl element.
Examples
xfi:items-in-instance($duplicates-instance) 
returns 
<acme:totalRevenue decimals="2" contextRef="c3" unitRef="u1"
>9832000</acme:totalRevenue>
<acme:totalRevenue decimals="2" contextRef="c3" unitRef="u1"
>9879000</acme:totalRevenue>$c3/xbrli:scenario
tuples-in-instance
xfi:tuples-in-instance($instance as element(xbrli:xbrl)) as schema-element(xbrli:tuple)*
Parameters
$instance	Instance document	
Return a sequence of tuples that are direct children of the main xbrli:xbrl element.
Examples
xfi:tuples-in-instance($duplicates-instance) 
returns 
$acme-instance/acme:additionalInformation
items-in-tuple
xfi:items-in-tuple($tuple as schema-element(xbrli:tuple)) as schema-element(xbrli:item)*
Parameters
$tuple	Container tuple	
Return a sequence of facts that are direct children of the $tuple element. 
Examples
xfi:items-in-tuple($acme-instance/acme:additionalInformation) 
returns a sequence with
( $acme-instance/acme:additionalInformation/acme:title,
$acme-instance/acme:additionalInformation/acme:author,
$acme-instance/acme:additionalInformation/acme:description )
tuples-in-tuple
xfi:tuples-in-tuple($tuple as schema-element(xbrli:tuple)) as schema-element(xbrli:tuple)*
Parameters
$tuple	Container tuple	
Return a sequence of tuples that are children of the $tuple parameter.
Examples
xfi:tuples-in-tuple($acme-instance/acme:additionalInformation) 
returns a sequence with
( $acme-instance/acme:additionalInformation/acme:title,
$acme-instance/acme:additionalInformation/acme:author,
$acme-instance/acme:additionalInformation/acme:description )
Predicates
Various predicates applicable to XBRL instances are defined in the XBRL 2.1 specification, Section 4.10. Bindings for these functions are defined in this specification. Specifically, these functions are s-equal, u-equal, v-equal, p-equal, c-equal and duplicate. 
identical-nodes
xfi:identical-nodes($left as node()*, $right as node()*) as xs:boolean
Parameters
$left 	The first node to compare.	
$right 	The second node to compare.	
Return the value as an xs:boolean of evaluating the identical node comparison on the list of node lists (or individual nodes).
Examples
xfi:identical-nodes($u1, $u2) returns xs:boolean("false")
xfi:identical-nodes($u1/xbrli:measure,$u2/xbrli:measure) returns xs:boolean("false")
xfi:identical-nodes($c1, $c1) returns xs:boolean("true")
xfi:identical-nodes(($c1,$c2),($c2,$c1)) returns("false")
xfi:identical-nodes(($c1,$c2),($c1,$c2)) returns("true")
s-equal 
xfi:s-equal($left as node()*, $right as node()*) as xs:boolean
Parameters
$left 	The first node to compare.	
$right 	The second node to compare.	
Return the value as an xs:boolean of evaluating the s-equal predicate on the list of node lists (or individual nodes).
Examples
xfi:s-equal($u1, $u2) returns xs:boolean("false")
xfi:s-equal($u1/xbrli:measure,$u2/xbrli:measure) returns xs:boolean("true")
xfi:s-equal($c1, $c2) returns xs:boolean("false")
u-equal 
xfi:u-equal($left as node()*, $right as node()*) as xs:boolean
Parameters
$left 	Sequence of items to compare.	
$right 	Sequence of items to compare with.	
Returns the value as an xs:boolean of evaluating the u-equal predicate for the supplied items.
For elements not derived from xbrli:item the dynamic error xfie:NodeIsNotXbrlItem MUST be raised.
Examples
xfi:u-equal($totalRevenue1, $totalExpenditure) returns xs:boolean("true")
xfi:u-equal($totalRevenue2, $revenueByGeographicSegmentUS) returns xs:boolean("false")
v-equal 

xfi:v-equal($left as node()*, $right as node()*) as xs:boolean
Parameters
$left 	Sequence of items to compare.	
$right 	Sequence of items to compare with.	
Returns the value as an xs:boolean of evaluating the v-equal predicate for the supplied items.
For elements not derived from xbrli:item the dynamic error xfie:NodeIsNotXbrlItem MUST be raised.
Examples
xfi:v-equal($totalExpenditure, $revenueByGeographicSegmentUS) returns xs:boolean("false")
c-equal 
xfi:c-equal($left as node()*, $right as node()*) as xs:boolean
Parameters
$left 	Sequence of items to compare.	
$right 	Sequence of items to compare with.	
Returns the value as an xs:boolean of evaluating the c-equal predicate for the supplied items.
For elements not derived from xbrli:item the dynamic error xfie:NodeIsNotXbrlItem MUST be raised.
Examples
xfi:c-equal($totalExpenditure, $title) returns xs:boolean("false").
xfi:c-equal($totalExpenditure, $totalRevenue1) returns xs:boolean("true").
identical-node-set 
xfi:identical-node-set($left as node()*, $right as node()*) as xs:boolean
Parameters
$left 	Sequence of items to compare.	
$right 	Sequence of items to compare with.	
Returns the value as an xs:boolean of evaluating the identical-nodes comparison over a set of nodes.
Examples
xfi:identical-node-set(($c1,$c2),($c2,$c1)) returns("true")
xfi:identical-node-set(($c1,$c2),($c1,$c2)) returns("true")
xfi:identical-node-set(($c1,$u1),($u1,$c1)) returns("true")
xfi:identical-node-set(($c1,$u2),($u1,$c1)) returns("false")
s-equal-set 
xfi:s-equal-set($left as node()*, $right as node()*) as xs:boolean
Parameters
$left 	Sequence of items to compare.	
$right 	Sequence of items to compare with.	
Returns the value as an xs:boolean of evaluating the s-equal predicate for the supplied set of items.
Examples
v-equal-set 
xfi:v-equal-set($left as node()*, $right as node()*) as xs:boolean
Parameters
$left 	Sequence of items to compare.	
$right 	Sequence of items to compare with.	
Returns the value as an xs:boolean of evaluating the v-equal predicate for the supplied set of items.
For elements not derived from xbrli:item the dynamic error xfie:NodeIsNotXbrlItem MUST be raised.
Examples
c-equal-set 
xfi:s-equal-set($left as node()*, $right as node()*) as xs:boolean
Parameters
$left 	Sequence of items to compare.	
$right 	Sequence of items to compare with.	
Returns the value as an xs:boolean of evaluating the c-equal predicate for the supplied set of items.
For elements not derived from xbrli:item the dynamic error xfie:NodeIsNotXbrlItem MUST be raised.
Examples
u-equal-set 
xfi:u-equal-set($left as node()*, $right as node()*) as xs:boolean
Parameters
$left 	Sequence of items to compare.	
$right 	Sequence of items to compare with.	
Returns the value as an xs:boolean of evaluating the u-equal predicate for the supplied set of items.
For elements not derived from xbrli:item the dynamic error xfie:NodeIsNotXbrlItem MUST be raised.
Examples
x-equal 
xfi:c-equal($left as node()*, $right as node()*) as xs:boolean
Parameters
$left 	Sequence of items to compare.	
$right 	Sequence of items to compare with.	
Returns the value as an xs:boolean of evaluating the x-equal predicate for the supplied items.
Examples
duplicate-item 
xfi:duplicate-item($left as schema-element(xbrli:item), $right as schema-element(xbrli:item)) as xs:boolean
Parameters
$left 	The first item to compare.	
$right 	The second item to compare.	
Returns true for items that are duplicates, return false otherwise.
Examples
xfi:duplicate-item($duplicateItem, $duplicateItem) returns xs:boolean("false")
duplicate-tuple 
xfi:duplicate-tuple($left as schema-element(xbrli:tuple), $right as schema-element(xbrli:tuple)) as xs:boolean
Parameters
$left 	The first tuple to compare.	
$right 	The second tuple to compare.	
Returns true for tuples that are duplicates, returns false otherwise.
Examples
xfi:duplicate-tuple($duplicateTuple, $duplicateTuple) returns xs:boolean("false")
p-equal 
xfi:p-equal($left as element(), $right as element()) as xs:boolean
Parameters
$left 	The first fact or tuple to compare.	
$right 	The second fact or tuple to compare with.	
Returns true for facts that are p-equal, returns false otherwise.
Examples
xfi:p-equal($totalExpenditure, $revenueByGeographicSegmentUS) returns xs:boolean("true")
xfi:p-equal($totalExpenditure, $title) returns xs:boolean("false")
cu-equal 
xfi:cu-equal($left as node()*, $right as node()*) as xs:boolean
For elements not derived from xbrli:item the dynamic error xfie:NodeIsNotXbrlItem MUST be raised.
Parameters
$left 	The first fact to compare.	
$right 	The second fact to compare.	
Returns true for facts that are both c-equal and u-equal, returns false otherwise. 
Examples
xfi:cu-equal($totalExpenditure, $totalRevenue1) returns xs:boolean("true")
xfi:cu-equal($totalExpenditure, $revenueByGeographicSegmentUS) returns xs:boolean("false")
xfi:cu-equal($title, $title) returns xs:boolean("true")
xfi:cu-equal($title, $totalExpenditure) returns xs:boolean("false")
pc-equal 
xfi:pc-equal($left as node()*, $right as node()*) as xs:boolean
For elements not derived from xbrli:item the dynamic error xfie:NodeIsNotXbrlItem MUST be raised.
Parameters
$left 	The first fact to compare.	
$right 	The second fact to compare.	
Returns true for facts that are both c-equal and p-equal, returns false otherwise. 
Examples
xfi:pc-equal($totalExpenditure, $totalRevenue1) returns xs:boolean("true")
xfi:pc-equal($totalExpenditure, $tittle) returns xs:boolean("false")
pcu-equal 
xfi:pcu-equal($left as node()*, $right as node()*) as xs:boolean
Parameters
$left 	The first fact to compare.	
$right 	The second fact to compare.	
Returns true for facts that are both c-equal and u-equal and p-equal, returns false otherwise. 
For elements not derived from xbrli:item the dynamic error xfie:NodeIsNotXbrlItem MUST be raised.
Examples
xfi:pcu-equal($totalExpenditure, $totalRevenue1) returns xs:boolean("true")
xfi:pcu-equal($totalExpenditure, $revenueByGeographicSegmentUS) returns xs:boolean("false")
xfi:pcu-equal($title, $title) returns xs:boolean("true")
xfi:pcu-equal($title, $totalExpenditure) returns xs:boolean("false")
Constructor Functions
Whereas the accessor functions give access to the various components of existing XBRL constructs a constructor function is a means of creating a new element. 
Constructor functions are defined for all XML Schema built-in types in http://www.w3.org/TR/xquery-operators/#func-signatures. 
The constructor functions specified herein allow the creation of new elements in an XBRL-specific fashion. 
WcH: All constructors need to be able to specify any other attribute that the content model allows.
WcH: Perhaps $id should be a distinguished argument here instead of just one of the $attrs.
Creating items
In order to create items, the following functions are defined. 
create-numeric-item-precision 
xfi:create-numeric-item-precision($name as xs:QName, $taxonomies as xs:anyURI*, $value as xdt:untypedAtomic, $context as element(xbrli:context), $unit as element(xbrli:unit), $precision as xbrli:precisionType, $attrs as attribute()*) as schema-element(xbrli:item)
Parameters
$name	The qualified name of the numeric item to create.	
$taxonomies	URIs of the taxonomies in one of which $name is defined.	
$value	The value that the new item should contain.	
$context	The context of the new item.	
$unit	The unit of the new item.	
$precision	The precision of the item.	
$attrs 	Additional user-supplied attributes.	
This creates a numeric item with the given name.  The item has the specified precision. If the name is not resolved to appropriate element which is substitutionGroup of xbrli:item and its type is numeric, dynamic error xfie:QNameIsNotNumericItem occur. If value is not valid against the item type resolved from name, dynamic error xfie:InvalidValue occur. If context does not match item’s period type, dynamic error xfie:MismatchingContextApplied occur. If unit does not match item’s unit restriction, dynamic error xfie:MismatchingUnitApplied occur.
Examples
xfi:create-numeric-item-precision(QName("http://example.com/acme/results/2003-07-01","acme:totalRevenue"),xs:anyURI("examples/taxonomy/acme.xsd"),"5234700", $c1,$u1,"INF",()) 
returns a copy of $totalRevenue1
create-numeric-item-decimals
xfi:create-numeric-item-decimals($name as xs:QName, $taxonomies as xs:anyURI*, $value as xs:anyType, $context as element(xbrli:context), $unit as element(xbrli:unit), $decimals as xbrli:decimalsType, $attrs as attribute()*) as schema-element(xbrli:item)
Parameters
$name	The qualified name of the numeric item to create.	
$taxonomies	URIs of the taxonomies in one of which $name is defined.	
$value	The value that the new item should contain.	
$context	The context of the new item.	
$unit	The unit of the new item.	
$decimals	The decimal places.	
$attrs 	Additional user-supplied attributes.	
This creates a numeric item with the given name. The behaviour is as per create-numeric-item-precision except that the new element has the supplied decimals rather than precision. If the name is not resolved to appropriate element which is substitutionGroup of xbrli:item and its type is numeric, dynamic error xfie:QNameIsNotNumericItem occur. If value is not valid against the item type resolved from name, dynamic error xfie:InvalidValue occur. If context does not match item’s period type, dynamic error xfie:MismatchingContextApplied occur. If unit does not match item’s unit restriction, dynamic error xfie:MismatchingUnitApplied occur.
Examples
xfi:create-numeric-item-decimals( QName("http://example.com/acme/results/2003-07-01","acme:totalRevenue"),xs:anyURI("examples/taxonomy/acme.xsd"),"9832000", $c3,$u2,2, ()) 
returns a copy of $totalRevenue2
create-non-numeric-item 
xfi:create-non-numeric-item($name as xs:QName, $taxonomies as xs:anyURI*, $value as xs:anyType, $context as element(xbrli:context), $attrs as attribute()*) as schema-element(xbrli:item)
Parameters
$name	The qualified name of the numeric item to create.	
$taxonomies	URIs of the taxonomies in one of which $name is defined.	
$value	The value that the new item should contain.
WcH:  If $value is xs:anyType that leaves the question of how the value would be formatted.  Would it not be better to make $value an xs:string ?	
$context	The context of the new item.	
$attrs 	Additional user-supplied attributes.	
This returns a non-numeric item with the given name. If the name is not resolved to appropriate element which is substitutionGroup of xbrli:item and its type is numeric, dynamic error xfie:QNameIsNotNonNumericItem occur. If value is not valid against the item type resolved from name, dynamic error xfie:InvalidValue occur. If context does not match item’s period type, dynamic error xfie:MismatchingContextApplied occur. 
Examples
xfi:create-non-numeric-item( QName("http://example.com/acme/results/2003-07-01","acme:title"),xs:anyURI("examples/taxonomy/acme.xsd"),"Acme results for the third quarter 2002",$c2, ()) 
returns a copy of $title
create-nil-item 
WcH: Nil items can be either numeric or non-numeric, so this function probably shouldn’t exist at all, rather there should be a Boolean $nil argument of create-{non-}numeric-item functions.
xfi:create-nil-item($name as xs:QName, $taxonomies as xs:anyURI*, $context as element(xbrli:context) , $attrs as attribute()*) as schema-element(xbrli:item)
xfi:create-nil-item($name as xs:QName, $taxonomies as xs:anyURI*, $context as element(xbrli:context), $unit as element(xbrli:unit) , $attrs as attribute()*) as schema-element(xbrli:item)
Parameters
$name	The name of the item.	
$taxonomies	URIs of the taxonomies in one of which $name is defined.	
$context	The context of the item.	
$unit	The unit of the item, required for numeric items.	
$attrs	Additional user-supplied attributes.	
This returns a nil item (that is, with the attribute xsi:nil="true") and with the given name and context.  The version that takes a unit is to be used for numeric items. If the name is not resolved to appropriate element which is substitutionGroup of xbrli:item, dynamic error xfie:QNameIsNotItem occur. If context does not match item’s period type, dynamic error xfie:MismatchingContextApplied occur. If unit does not match item’s unit restriction, dynamic error xfie:MismatchingUnitApplied occur.
DVK: What we really need to do is match the XML Schema content model exactly, including the possibility of attributes from other namespaces.
Examples
xfi:create-nil-item(QName("http://example.com/acme/results/2003-07-01","acme:title"),xs:anyURI("examples/taxonomy/acme.xsd"),$c2,()) 
returns the element "<acme:title xsi:nil="true" contextRef="c2" />"
Creating tuples
It is necessary to create a tuple, either from the existing items and tuples or from the content of an existing XBRL instance. 
create-tuple 
xfi:create-tuple($name as xs:QName, $taxonomies as xs:anyURI*, $facts as element()* , $attrs as attribute()*) as schema-element(xbrli:tuple)
Parameters
$name	The name for the new tuple.	
$taxonomies	URIs of the taxonomies in one of which $name is defined.	
$facts	The list of child facts that the new tuple must contain.	
$attrs	Additional user-supplied attributes.	
Returns the newly created tuple that must contain the child facts in the order specified, with the given name. If the name is not resolved to appropriate element which is substitutionGroup of xbrli:tuple, dynamic error xfie:QNameIsNotTuple occur. If facts are not valid against the tuple content type, dynamic error xfie:InvalidContentType occur. 
Examples
xfi:create-tuple(QName("http://example.com/acme/results/2003-07-01","acme:companyWebsite"),xs:anyURI("examples/taxonomy/acme.xsd"),(),()) returns "<acme:companyWebsite />"
Creating contexts
Included are functions for creating contexts and their sub-elements. Contexts may be created from scratch and by copying existing contexts or their sub-components. 
Periods
In XBRL there are three kinds of periods – forever, instants and start/end periods.  A different constructor function is supplied for each kind of period.  Create-period is polymorphic.
create-period 
xfi:create-period() as element(xbrli:period)
Parameters
No parameters.  Return a forever period.
Examples
xfi:create-period() returns the element "<period><forever/></period>"
create-period 
xfi:create-period-date($instant as xs:date) as element(xbrli:period)
xfi:create-period-dateTime($instant as xs:dateTime) as element(xbrli:period)

Parameters
$instant	The date or date time for the new instant.	
Return a new instant period with the given date.
Examples
xfi:create-period-date(xs:date("1958-10-19")) returns the element "<period><instant>1958‑10‑19</instant></period>"
create-period 
xfi:create-period-date($start as xs:date, $end as xs:date) as element(xbrli:period)
xfi:create-period-dateTime($start as xs:dateTime, $end as xs:dateTime) as element(xbrli:period)
Parameters
$start	The start date or date time.	
$end	The end date or date time.	
Return a new start/end date style period. The start date must occur before the end date or else the dynamic error xfie:StartDateNotPrecedingEndDate occurs.
Examples
xfi:create-period-date(xs:date("1958-10-19"),xs:date("2000-04-04")) returns the element 

<period>
  <startDate>1958‑10‑19</startDate>
  <endDate>2000‑04‑04</endDate>
</period>
Entity, Segments and Scenario Constructors
The segments and scenarios are supplied as lists of nodes since in general they are simply containers for freeform XML. A constructor function is supplied for creating entities. 
create-entity 
xfi:create-entity($identifier as xs:token, $scheme as xs:anyURI, $segment as node()*) as element(xbrli:entity)
Parameters
$identifier	The entity identifier.	
$scheme	The entity identifier scheme.	
$segment	The nodes to appear in the segment.	
This function creates a new entity element from scratch using the supplied data.
Examples
xfi:create-entity(xs:token("example.com"),xs:anyURI("http://nic.net"),()) returns the element 

<entity>
  <identifier scheme="http://nic.net">example.com</identifier>
</entity>
Context Constructors
New contexts may be created either directly from their constituent parts (periods and entities for example) or based on existing contexts. 
create-context 
xfi:create-context($period as element(xbrli:period), $entity as element(xbrli:entity), $scenario as node()*, $id as xs:string) as element(xbrli:context)
Parameters
$period	The period of the new context.	
$entity	The entity of the new context.	
$scenario	The scenario of the new context.	
$id	The id of the new context.	
Returns a new context constructed from the various constituent elements in a context.
Examples
xfi:create-context(xfi:context-period($c1),xfi:context-entity($c1),xfi:context-scenario($c1),$c1/@id) 
returns a copy of $c1
create-start-instant-context 
xfi:create-start-instant-context($context as element(xbrli:context), $id as xs:string) as element(xbrli:context)
Parameters
$context	The base context.	
$id	The id of the new context.	
Creates a new context equivalent to the supplied context (which must have a start-end date style period, or else the dynamic error xfie:PeriodIsForever or the dynamic error xfie:PeriodIsNotStartEnd is raised) except that the period is an instant equal to the value of ‘xfi:period‑start($context)’
Examples
xfi:create-start-instant-context($c1,"c1start") returns the element 

  <context id="c1start">
    <entity>
      <identifier scheme="http://example.com/acme/results">Acme</identifier>
    </entity>
    <period>
      <instant>2004-03-31T00:00:00</instant>
    </period>
  </context>
create-end-instant-context 
xfi:create-end-instant-context($context as element(xbrli:context), $id as xs:string) as element(xbrli:context)
Parameters
$context	The base context.	
$id	The id of the new context.	
 As per xfi:create-start-instant-context, except that the instant takes the value of ‘period-end($context)’.
Examples
xfi:create-end-instant-context($c1,"c1end") returns the element 
  <context id="c1end">
    <entity>
      <identifier scheme="http://example.com/acme/results">Acme</identifier>
    </entity>
    <period>
      <instant>2005-03-30T00:00:00</instant>
    </period>
  </context>
create-context-from-instant-contexts 
xfi:create-context-from-instant-contexts($left as element(xbrli:context), $right as element(xbrli:context), $id as xs:string) as element(xbrli:context)
Parameters
$left	The first context, which must be an instant.	
$right	The second context, which must be an instant.	
$id	The id for the new context.	
Returns a duration (start-end style) context starting from xfi:period‑instant($left) and ending on xfi:period‑instant($right).  
If either of the contexts is not an instant, then the dynamic error xfie:PeriodIsNotInstant is raised. If the entities (and the respective scenarios) of the contexts are not s-equal, then the dynamic error xfie:InconsistentContexts occurs. 
If the first instant is not before the second instant, then the dynamic error xfie:StartDateNotPrecedingEndDate occurs.
Examples
xfi:create-context-from-instant-contexts(fi:create-start-instant-context($c1,"cx"), $c2, "c1end") 
Return the element 
  <context id="c1end">
    <entity>
      <identifier scheme="http://example.com/acme">Acme</identifier>
    </entity>
    <period>
      <startDate>2004-03-31T00:00:00</startDate>
      <endDate>2004-11-18T00:00:00</endDate>
    </period>
  </context>

xfi:create-context-from-instant-contexts($c2, fi:create-start-instant-context($c1,"cx"),"c1end") raises error xfie:StartDateNotPrecedingEndDate
Unit Constructors
As well as functions for creating new units, there are additionally functions for performing ‘unit arithmetic’, in the sense of multiplying and inverting units.  These allow the automatic computation of the units of a calculation.  
Note that the measure for the QName xbrli:pure must be treated as a multiplicative identity so that for any measure $measure:
<measure>xbrli:pure</measure> * $measure = $measure = $measure * <measure>xbrli:pure</measure> 

create-unit 
xfi:create-unit($numerator as xs:QName+, $denominator as xs:QName*, $id as xs:string) as element(xbrli:unit)
Parameters
$numerator	The non-empty list of measure QNames to appear as numerators or as children of the unit.	
$denominator	The list of denominator measure QNames.	
$id	The id for the new unit.	
Return a new unit using the supplied numerator and denominator with the given id. If the denominator is empty, then no divide element occurs and the measures are direct children of the new unit. Otherwise, a divide element occurs and the numerator measures occur as children of the unitNumerator element, whilst the denominator measures occur as children of the unitDenominator element. The resulting measure should be in its simplest form, as per XBRL specification Section 4.8.4.  In particular, any cancellable measures should be eliminated and pure units should be reduced. 
Examples
 xfi:create-unit(
QName("http://www.xbrl.org/2003/iso4217","iso4217:USD"),
QName("http://www.xbrl.org/2003/instance","xbrli:shares"),
"usdPerShare") returns
  <unit id="usdPerShare">
    <divide>
      <unitNumerator>
        <measure xmlns:iso4217="http://www.xbrl.org/2003/iso4217">iso4217:USD</measure>
      </unitNumerator>
      <unitDenominator>
        <measure xmlns:xbrli="http://www.xbrl.org/2003/instance">xbrli:shares</measure>
      </unitDenominator>
    </divide>
</unit>

xfi:create-unit(
(QName("http://www.xbrl.org/2003/iso4217","iso4217:USD"),
QName("http://www.xbrl.org/2003/instance","xbrli:pure",
QName("http://www.xbrl.org/2003/instance","xbrli:decimal"),  (QName("http://www.xbrl.org/2003/instance","xbrli:decimal",
QName("http://www.xbrl.org/2003/instance","xbrli:shares"),
"usdPerShare") returns
  <unit id="usdPerShare">
    <divide>
      <unitNumerator>
        <measure xmlns:iso4217="http://www.xbrl.org/2003/iso4217">iso4217:USD</measure>
      </unitNumerator>
      <unitDenominator>
        <measure xmlns:xbrli="http://www.xbrl.org/2003/instance">xbrli:shares</measure>
      </unitDenominator>
    </divide>
</unit>
create-product-unit 
xfi:create-product-unit($units as element(xbrli:unit)*, $id as xs:string) as element(xbrli:unit)
Parameters
$units	The list of units.	
$id	An id for the new unit.	
Return a new unit which is the product of the supplied unit arguments using the given id.  
If the list is empty then the pure unit is used (that is, a unit with an empty denominator and a numerator consisting of a single measure xbrli:pure). 
Examples
xfi:create-product-unit((),"u") return
  <unit id="u">
    <measure>pure</measure>
</unit>

xfi:create-product-unit(
(create-unit(
QName("http://www.xbrl.org/2003/iso4217","iso4217:USD"),(),"void"),
 create-unit(
QName("http://www.xbrl.org/2003/instance","xbrli:pure"),(),"void")
	)
,"u") return
  <unit id="u">
    <measure xmlns:iso4217="http://www.xbrl.org/2003/iso4217">iso4217:USD</measure>
</unit>

xfi:create-product-unit(
(create-unit(
QName("http://www.xbrl.org/2003/iso4217","iso4217:USD"),(),"void"),
	 create-unit(
QName("http://www.xbrl.org/2003/iso4217","iso4217:USD"),(),"void")
	)
,"u") return
  <unit id="u">
    <measure xmlns:iso4217="http://www.xbrl.org/2003/iso4217">iso4217:USD</measure>
    <measure xmlns:iso4217="http://www.xbrl.org/2003/iso4217">iso4217:USD</measure>
</unit>
create-inverse-unit 
xfi:create-inverse-unit($unit as element(xbrli:unit), $id as xs:string) as element(xbrli:unit) 
Parameters
$unit 	The unit to invert.	
$id	An id for the new unit.	
Return a new unit that is the inverse of the supplied unit using the given id. Note that the inverse of the pure measure is again the pure measure. 
Examples
xfi:create-inverse-unit(xfi:create-unit(
QName("http://www.xbrl.org/2003/instance","xbrli:pure"),(),"p"), "p") 
return
<unit id="p">
<measure xmlns:xbrli="http://www.xbrl.org/2003/instance">xbrli:pure</measure>
</unit>

xfi:create-inverse-unit(
<xbrli:unit id="uid">
	<xbrli:divide xmlns:iso4217="http://www.xbrl.org/2003/iso4217">
		<xbrli:unitNumerator>
			<xbrli:measure>iso4217:USD</xbrli:measure>
		</xbrli:unitNumerator>
		<xbrli:unitDenominator>
			<xbrli:measure>shares</xbrli:measure>
		</xbrli:unitDenominator>
	</xbrli:divide>
</xbrli:unit>
, "p") 
return
<xbrli:unit id="p">
	<xbrli:divide xmlns:iso4217="http://www.xbrl.org/2003/iso4217">
		<xbrli:unitNumerator>
			<xbrli:measure>shares</xbrli:measure>
		</xbrli:unitNumerator>
		<xbrli:unitDenominator>
			<xbrli:measure>iso4217:USD</xbrli:measure>
		</xbrli:unitDenominator>
	</xbrli:divide>
</xbrli:unit>
Creating instances
A user will need to assemble various components into complete XBRL instances. In order to perform this, the following functions are supplied. 
Firstly, it will be necessary on occasion to explicitly add schemaRef and linkbaseRef elements as necessary to the XBRL instance. 
create-schemaRef 
xfi:create-schemaRef($location as xs:anyURI) as element(link:schemaRef)
Parameters
$location	The URI reference of the schema to be referenced.	
Returns a new link:schemaRef with xlink:href equal to the supplied URI.
Examples
xfi:create-schema-ref(xs:anyURI("taxonomy/acme.xsd)) returns

<link:schemaRef xlink:type="simple" xlink:href="taxonomy/acme.xsd"/>
create-linkbaseRef 
xfi:create-linkbaseRef($location as xs:anyURI,$role as xs:anyURI) as element(link:linkbaseRef)
Parameters
$location	The URI reference of the linkbase to be referenced.	
$role	The optional role of the linkbaseRef	
Returns a new link:linkbaseRef with xlink:href equal to the supplied URI and role, if supplied.
Examples
xfi:create-linkbaseRef(xs:anyURI("my-2005-04-31.xml"), xs:anyURI("http://wwwx.xbrl.org/2003/role/presentationLinkbaseRef")) returns
<link:linkbaseRef xlink:href="my-2005-04-31.xml" xlink:type="simple" xlink:role="http://wwwx.xbrl.org/2003/role/presentationLinkbaseRef"  xlink:arcrole="http://www.w3.org/1999/xlink/properties/linkbase"/>
create-instance 
xfi:create‑instance($refs as schema-element(xl:simple)+, $contexts as element(xbrli:context)*, $units as element(xbrli:unit)* , $facts as element()*, $footnotes as element(link:footnoteLink)*) as document-node(element(xbrli:xbrl))
Parameters
$refs 	The list of references to appear at the start of the new instance. This must include at least one link:schemaRef element. Note that the linkbase references will appear in the order specified.	
$contexts	The list of contexts the new instance should contain.	
$units	The list of units the new instance should contain.	
$facts	The list of facts to appear as children of the new instance.	
$footnotes	The sequence of footnote links the new instance should contain.	
Return a new instance containing the supplied facts, contexts, units and footnotes. The output instance document MUST be validated against the http://www.xbrl.org/2003/instance schema but may not be a valid XBRL document if validated against the XBRL specification.
Examples
xfi:create‑instance(xfi:create-schemaRef(xs:anyURI("my-2006-12-07.xsd")),(),(),(),()) returns an empty instance.
Creating footnotes
Footnotes can be created dynamically and added to an instance document as a parameter to the create-instance function. Te following functions helps in the creation of the link:footnoteLink element, footnote resources, arcs and locators.
create-footnoteLink
xfi:create-footnoteLink($role as xs:anyURI, $footnotes as schema-element(link:footnote)+, $footnoteLocs as schema-element(xl:locator)+, $footnoteArcs as schema-element(xl:arc)+) as element(link:footnoteLink)
Parameters
$role 	The content of the xlink:role attribute	
$footnotes	Footnote resources that will be included as content of the link:footnoteLink element.	
$footnoteLocs	Locators to facts.	
$footnoteArcs	Arcs connecting the resources to the locators.	
Return a link:footnoteLink element with the corresponding content.
Examples
xfi:create-footnoteLink(
	xs:anyURI(/"http://www.xbrl.org/2003/role/link"), 
	xfi:create-footnote(
		xs:NCName("res_note"),
		xs:anyURI("http://www.xbrl.org/2003/role/footnote"),
		xs:language("en"),(),"Text of the note1"
	),
	(
		xfi:create-loc(xs:anyURI("#note1"),xs:NCName("loc_notes1and2")),
		xfi:create-loc(xs:anyURI("#note2"),xs:NCName("loc_notes1and2"))
	),
	xfi:create-footnoteArc(
		xs:NCName("loc_notes1and2"),
		xs:NCName("res_note"),
		xs:anyURI("http://www.xbrl.org/2003/arcrole/fact-footnote"),
		()
	)
) 
returns 
<link:footnoteLink xlink:role="http://www.xbrl.org/2003/role/link" xlink:type="extended">
	<link:footnote xlink:type="resource" xlink:label="res_note" xlink:role="http://www.xbrl.org/2003/role/footnote" xml:lang="en">Text of the note1</link:footnote>
	<link:loc xlink:type="locator" xlink:href="#note1" xlink:label="loc_notes1and2"/>
	<link:loc xlink:type="locator" xlink:href="#note2" xlink:label="loc_notes1and2"/>
	<link:footnoteArc xlink:type="arc" xlink:to="res_note" xlink:from="loc_notes1and2" xlink:arcrole="http://www.xbrl.org/2003/arcrole/fact-footnote"/>
</link:footnoteLink>
create-footnote
xfi:create-footnote($label as xs:NCName, $role as xs:anyURI, $lang as xs:language, $attrs as attribute()*, $note as xs:string) as element(link:footnote)
Parameters
$label 	The resource label.	
$role	The value of the xlink:role attribute.	
$lang	The value of the xml:lang attribute.	
$attrs	Additional attributes if required.	
$note	The content of the footnote.	
Return a link:footnote resource.
Examples
xfi:create-footnote(
	xs:NCName("res_note1"),
	xs:anyURI("http://www.xbrl.org/2003/role/footnote"),
	xs:language("en"),
	(),
	"Aditional note for the note1"
) 
returns
<link:footnote xlink:type="resource" xlink:label="res_note1" xlink:role="http://www.xbrl.org/2003/role/footnote" xml:lang="en">Aditional note for the note1</link:footnote>
create-loc
xfi:create-loc($href as xs:anyURI, $label as xs:NCName) as element(link:loc)
Parameters
$href	The value of the xlink:href attribute.	
$label 	The locator label.	
Return a link:loc element. This is a generic function to create locators.
Examples
xfi:create-loc(xs:anyURI("#note1"),xs:NCName("loc_note1"))
returns
<link:loc xlink:type="locator" xlink:href="#note1" xlink:label="loc_note1"/>
create-footnoteArc
xfi:create-footnoteArc($from as xs:NCName, $to as xs:NCName, $arcrole as xs:anyURI, $attrs as attribute()*) as element(link:footnoteArc)
Parameters
$from	The value of the xlink:from attribute.	
$to 	The value of the xlink:to attribute.	
$arcrole	The value of the xlink:arcrole attribute. Usually http://www.xbrl.org/2003/arcrole/fact-footnote	
$attrs	Additional attributes if required.	
Return a link:footnoteArc element.
Examples
xfi:create-footnoteArc(
	xs:NCName("loc_note1"),
	xs:NCName("res_note1"),
	xs:anyURI("http://www.xbrl.org/2003/arcrole/fact-footnote"),
	()
)
returns
<link:footnoteArc xlink:type="arc" xlink:to="res_note1" xlink:from="loc_note1" xlink:arcrole="http://www.xbrl.org/2003/arcrole/fact-footnote"/>
Errors
Error	Meaning	
xfie:ItemIsNotNumeric	Item is not numeric.	
xfie:PeriodIsForever	Period must not be forever.	
xfie:PeriodIsNotInstant	Period is not an instant.	
xfie:PeriodIsNotStartEnd	Period is not a start / end duration.	
xfie:InconsistentContexts	Inconsistent entities, segments or scenarios.	
xfie:StartDateNotPrecedingEndDate	Beginning date does not precede end date.	
xfie:InconsistentContextsOrUnits	Inconsistent contexts or units with same id.	
xfie:QNameIsNotNumericItem	QName is not a numeric item.	
xfie:QNameIsNotNonNumericItem	QName is not a non numeric item.	
xfie:QNameIsNotItem	QName is not an item.	
xfie:QNameIsNotTuple	QName is not a tuple.	
xfie:MismatchingContextApplied	Context is not valid for an item.	
xfie:MismatchingUnitApplied	Unit is not valid for an item.	
xfie:InvalidValue	Value is not valid against the item type.	
xfie:InvalidContentType	Tuple content is not valid against the tuple content model.	
xfie:ElementIsNotDefinedInDTS	The element definition cannot be found in the files that are part of the DTS.	
xfie:NodeIsNotXbrlItem	Te node is not derived from xbrli:item	

Document history (non-normative)
Date	Editor	Remarks	
2005-03-30	Simmons	First draft of an internal working draft for the function specification is created	
2005-04-22	Hamscher	Formatting changes, added examples.	
2005-04-24	Hamscher	Added the requirement of a conformance suite and two interoperable implementations to the approval process.  Other typographical corrections.	
2005-06-07	Simmons	Incorporated comments by Walter Hamscher, Harald Schmitt and Atsushi Ohtake.	
2005-08-15	Fischer	Added c-equals and u-equals overloads for item to context/unit.	
2005-08-17	Hamscher	Reformatted document.  Rearrangement of document.  Gave errors mnemonic names.	
2005-09-23	Goto	Corrections of parameters in example. Sort parameter in several functions. Error code PeriodIsNotDuration is changed to PeriodIsNotStartEnd. Added new error codes for XBRL element creation error. Delete merge-instance method by the F2F result. Predicates functions can take context as parameter. Added new functions cu-equal, pc-equal and pcu-equal.	
2005-11-04	Ohtake	Corrections of some function’s signature in using union as "element(xbrli:period | xbrli:context)"  and "element(xbrli:entity | xbrli:context)" etc.	
2005-11-30	Simmons	Added more accessor functions to ease navigation of XBRL instances.  This is to remove the need for functions that take more than one parameter type because now anything should be accessible using at most two function calls.	
2005-12-12	Simmons	Added a decimals function.	
2006-01-20	IHR	Added functions to access information in XBRL taxonomies, added functions to deal with footnotes.	
2006-02-20	IHR	All functions are implemented in XQuery language according to the XQuery 1.0 CR-3.
A conformance suite with all examples within this document has been created.	
2006-03-15	IHR	Changed function names DTS-taxonomies to DTS-schemas. taxonomy-schema-from-QName to schema-from-QName and taxonomy-element-from-QName to schema-element-from-QName. Editorial changes in the documentation of some functions. Removed the cardinality * in the second parameter of arcs-in-base-set, locators-in-base-set and resources-in-base-set functions. Documented that xfi:period-end function when the period contains an xs:date, returns the dateTime for that date + 1 day.	
2006-05-24	IHR	Overall document review.
Added functions to create footnotes
The unit function returns the empty sequence if the fact is not numeric rather than raise xfie:ItemIsNotNumeric
Removed the error xfie:NonStandardMeasure and the functions that should raise it.	
2006-06-20	IHR	Removed all DTS functions
Removed all Taxonomy functions
Removed the decimals function
Renamed some functions that incorrectly had the word "fact" to use the word "item"
Added functions to compare sets of elements as described in table 4 of the XBRL 2.1 Specification.
Added x-equal function signature as defined in the XBRL 2.1 specification
Added identical nodes and identical-node-sets as defined in Table 4 of the XBRL 2.1 specification
Added page numbers and other editorial changes	
2006-10-16	IHR	Changed the returning value of the create-instance function to be a document-node(element(xbrli:xbrl)) document rather than just the xbrli:xbrl element.
Without that change the returned instance will never contain a document-uri and the xlink:href attributes cannot be evaluated to their absolute paths.	
2006-11-30	HW	Editorial to prepare for Public Working Draft publication	
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).
References (non-normative)

[FLINK]		
	Formula Linkbase	

[RFC2119]	Scott Bradner	
	Key words for use in RFCs to Indicate Requirement Levels, March 1997	
	http://www.ietf.org/rfc/rfc2119.txt 	
		
[XBRL]	Phillip Engel, Walter Hamscher, Geoff Shuetrim, David vun Kannon and Hugh Wallis	
	Extensible Business Reporting Language 2.1 Recommendation with corrected errata to 2004-11-14.	
	http://www.xbrl.org/Specification/XBRL-RECOMMENDATION-2003-12-31+Corrected-Errata-2005-04-25.rtf 	
		
[XQPFS]	Denise Draper. Peter Fankhauser. Mary Fernández. Ashok Malhotra. Kristoffer Rose. Michael Rys. Jérôme Siméon. Philip Wadler.	
	XQuery 1.0 and XPath 2.0 Formal Semantics	
	http://www.w3.org/TR/xquery-semantics/	
		
[XPath2]	Anders Berglund, Scott Boag, Don Chamberlin, Mary Fernández, Michael Kay, Jonathan Robie, and Jérôme Siméon	
	XPath 2.0	
	http://www.w3.org/TR/xpath20	
		
[XQuery]	Scott Boag, Don Chamberlin, Mary Fernández, Daniela Florescu, Jonathan Robie, Jérôme Siméon	
	XQuery 1.0: An XML Query Language	
	http://www.w3.org/TR/2005/CR-xquery-20051103/	
		
[Processes]	Walter Hamscher	
	XBRL International Processes 1.0, 4 April 2002	
	http://www.xbrl.org/