Data Format Description Language (DFDL) v1.0 Specification
OGF Proposed Recommendation GFD-P-R.174, January 31, 2011


23.5 Constructors, Functions and Operators

23.5.1 Constructor Functions for XML Schema Built-in Types

The following constructor functions for the built-in types are supported:

A Special Constructor Function for xs:dateTime

A special constructor function is provided for constructing a xs:dateTime value from an xs:date value and an xs:time value.

fn:dateTime($arg1 as xs:date?, $arg2 as xs:time?) as xs:dateTime?

23.5.2 Standard XPath Functions

23.5.2.1 Boolean functions

The following additional constructor functions are defined on the boolean type.

Function

Meaning

fn:true

Constructs the xs:boolean value 'true'.

fn:false

Constructs the xs:boolean value 'false'.

Table 27 Boolean functions

 

The following functions are defined on boolean values:

Function

Meaning

fn:not

Inverts the xs:boolean value of the argument.

Table 28 Boolean functions

 

23.5.2.2 Numeric functions

The following functions are defined on numeric types. Each function returns a value of the same type as the type of its argument.

Function

Meaning

Mfn:abs

Returns the absolute value of the argument.

fn:ceiling

Returns the smallest number with no fractional part that is greater than or equal to the argument.

fn:floor

Returns the largest number with no fractional part that is less than or equal to the argument.

fn:round

Rounds to the nearest number with no fractional part.

fn:round-half-to-even

Takes a number and a precision and returns a number rounded to the given precision. If the fractional part is exactly half, the result is the number whose least significant digit is even.

Table 29 Numeric functions

 

23.5.2.3 String functions

The following functions are defined on values of type xs:string and types derived from it.

Function

Meaning

fn:concat

Concatenates two or more xs:anyAtomicType arguments cast to xs:string.

fn:substring

Returns the xs:string located at a specified place within an argument xs:string.

fn:string-length

Returns the length of the argument.

fn:upper-case

Returns the upper-cased value of the argument.

fn:lower-case

Returns the lower-cased value of the argument.

fn:contains

Indicates whether one xs:string contains another xs:string. A collation may be specified.

fn:starts-with

Indicates whether the value of one xs:string begins with the collation units of another xs:string. A collation may be specified.

fn:ends-with

Indicates whether the value of one xs:string ends with the collation units of another xs:string. A collation may be specified.

fn:substring-before

Returns the collation units of one xs:string that precede in that xs:string the collation units of another xs:string. A collation may be specified.

fn:substring-after

Returns the collation units of xs:string that follow in that xs:string the collation units of another xs:string. A collation may be specified.

Table 30 String functions

 

23.5.2.4 Date, Time functions

Function

Meaning

fn:year-from-dateTime

Returns the year from an xs:dateTime value.

fn:month-from-dateTime

Returns the month from an xs:dateTime value.

fn:day-from-dateTime

Returns the day from an xs:dateTime value.

fn:hours-from-dateTime

Returns the hours from an xs:dateTime value.

fn:minutes-from-dateTime

Returns the minutes from an xs:dateTime value.

fn:seconds-from-dateTime

Returns the seconds from an xs:dateTime value.

fn:year-from-date

Returns the year from an xs:date value.

fn:month-from-date

Returns the month from an xs:date value.

fn:day-from-date

Returns the day from an xs:date value.

fn:hours-from-time

Returns the hours from an xs:time value.

fn:minutes-from-time

Returns the minutes from an xs:time value.

fn:seconds-from-time

Returns the seconds from an xs:time value.

Table 31 Date, Time functions

 

23.5.2.5 Sequences functions

The following functions are defined on sequences. (Note that DFDL v1.0 does not support sequences of length > 1.)

Function

Meaning

fn:empty

Indicates whether or not the provided sequence is empty.

fn:exists

Indicates whether or not the provided sequence is not empty.

Table 32 Sequences functions

 

23.5.2.6 Node functions

This section discusses functions and operators on nodes.

Function

Meaning

fn:name

Returns the name of the context node or the specified node as an xs:string.

fn:local-name

Returns the local name of the context node or the specified node as an xs:NCName.

fn:namespace-uri

Returns the namespace URI as an xs:anyURI for the xs:QName of the argument node or the context node if the argument is omitted. This may be the URI corresponding to the zero-length string if the xs:QName is in no namespace.

Table 33 Node functions

 

23.5.3 DFDL Functions

Function

Meaning

dfdl:representationLength

Returns the unparsed length the specified node as an xs:unsignedlong. The length is the number of 'bytes', 'characters' or 'bits' depending on second argument

dfdl:unpaddedLength

Returns the unpadded length the specified node as an xs:unsignedlong. The unpadded length excludes any padding or filling. The length is the number of 'bytes', 'characters' or 'bits' depending on second argument

dfdl:property

Returns the value of requested DFDL property of the specified node as an xs:string.

Ex dfdl:property( ‘byteorder’, ‘./address ‘)

dfdl:testbit

Returns Boolean true if the bit number given by arg #2 is set on in the byte given by arg #1, otherwise returns Boolean false.

dfdl:setBits

Returns an unsigned byte being the value of the bit positions provided by the Boolean arguments, where true=1, false=0. The number of arguments must be 8.

dfdl:countWithDefault

Returns the count the number of occurrences including the effect of defaulting as an xs:int

dfdl:count

Returns the number of occurrences in an array as an xs:int.

dfdl:position

Returns the position of the current item within an array as an xs:int.

dfdl:checkConstraints

Returns boolean true if the specified node value satisfies the XML schema constraints specified. Returns false if the specified node does not meet the constraints or does not exist.

Table 34 DFDL Functions

 

Notes:

dfdl:unpaddedLength(path) - returns the unpadded length which excludes any padding or filling which might be added for a specified lengthIf the element declaration in the DFDL schema corresponding to the infoset item is not potentially represented, then the unpadded length is defined to be 0.The unpadded length includes the length contributions from introduced escape characters required to escape contained delimiters (if such are defined, and will appear in the output representation). The unpadded length is also a function of the dfdl:encoding property. Multi-byte and variable-width character set encodings will commonly contribute more bytes to the unpadded length than a single-byte character set would. The unpadded length is computed from the DFDL infoset value, ignoring the dfdl:length or dfdl:textOutputMinLength property. Other DFDL properties which affect the length of a text or binary representation are respected, it is only an explicit length which is ignored.For a complex type, this means a bottom up totaling of the dfdl:representationLength() of all the contents and framing of the complex type.

dfdl:representationLength(path) – returns the length of the representation of the infoset data item as identified by the path argument. This includes padding or filling or truncation which might be carried out for a specified length item.

If the element declaration in the DFDL schema corresponding to the infoset item is not potentially represented, then the length is defined to be 0.

When unparsing with dfdl:lengthKind="explicit", the calculation of dfdl:representationLength() returns the value of the dfdl:length property.

For both dfdl:representationLength and dfdl:unpaddedLength, the representation length excludes any alignment filling as well as excluding any leading or trailing skip bytes. That is, the returned length is about the length of the content, and not about the position of that content in the output data stream.


Copyright (C) Open Grid Forum (2005-2010). All Rights Reserved.

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 the OGF or other organizations, except as needed for the purpose of developing Grid Recommendations in which case the procedures for copyrights defined in the OGF Document process must be followed, or as required to translate it into languages other than English.