W3Schools

home HOME

XForms Tutorial
XForms HOME
XForms Intro
XForms Model
XForms Namespace
XForms Example
XForms XPath
XForms Input
XForms Selections
XForms Datatypes
XForms Properties
XForms Actions
XForms Functions

References
XForms Datatypes

Selected Reading
Web Statistics
Web Glossary
Web Hosting
Web Quality

W3Schools Forum

Helping W3Schools

XForms Functions

prev next

XForms has some predefined functions. But you can also call functions defined in scripts.


XForms Functions

The XForms function library includes the entire XPath 1.0 core function library.

The XPath core functions can be found here: http://www.w3schools.com/xpath/xpath_functions.asp

The following table lists the additional functions within XForms:

Function Description
boolean-from-string(string) Returns true if the parameter string is "true" or "1" and false if the parameter string is "false" or "0"
if(booleantest, string1, string2) Evaluates the Booleantest parameter and returns string1 if the test is true, and string2 if the test is false
avg(node-set) Returns the average of all the nodes in the specified node-set. The value of each node is converted to a number. If the node-set is empty it returns NaN

<values>
<value>10</value>
<value>50</value>
<value>0</value>
</values>

avg(/values/value)

Returns: 20
min(node-set) Returns the minimum value of all the nodes in the specified node-set. The value of each node is converted to a number. If the node-set is empty it returns NaN

<values>
<value>10</value>
<value>20</value>
<value>0</value>
</values>

min(/values/value)

Returns: 0
max(node-set) Returns the maximum value of all the nodes in the specified node-set. The value of each node is converted to a number. If the node-set is empty it returns NaN

<values>
<value>10</value>
<value>20</value>
<value>0</value>
</values>

max(/values/value)

Returns: 20
count-non-empty(node-set) Returns the number of non-empty nodes in the specified node-set

<values>
<value>10</value>
<value>20</value>
<value>0</value>
<value />
</values>

count-non-empty(/values/value)

Returns: 3
index(string) Returns the current index for a given repeat set
property(string) Returns the property named by the string parameter
  • property("version") - returns the XForms version number
  • property("conformance-level") - returns the XForms conformance level ("basic" or "full")
now() Returns the current system date and time in xs:dateTime format
instance(string) An XForms Model can contain more than one instance. This function returns the root node of the specified instance data

<xforms:instance id="orderform">
<firstName>John</firstName>
</xforms:instance>

ref="instance('orderform')/firstName"

This example returns a node-set that consists of the firstName element node from the instance named "orderform"

days-from-date(string) If the string parameter represents a legal xs:date or xs:dateTime, it returns the number of days between the specified date and 1970-01-01, otherwise it returns NaN

days-from-date("2002-01-02") returns 11689
days-from-date("1969-12-29") returns -3

seconds-from-dateTime(string) If the string parameter represents a legal xs:dateTime, it returns the number of seconds between the specified dateTime and 1970-01-01T00:00:00Z, otherwise it returns NaN
seconds(string) If the string parameter represents a legal xs:duration, it returns the number specified in the seconds component plus 60 * the number specified in the minutes component, plus 60 * 60 * the number specified in the hours component, plus 60 * 60 * 24 * the number specified in the days component, otherwise it returns NaN

seconds("P1Y2M") returns 0
seconds("P3DT10H30M1.5S") returns 297001.5
seconds("3") returns NaN

months(string) If the string parameter represents a legal xs:duration, it returns the number specified in the months component plus 12 * the number specified in the years component, otherwise it returns NaN

months("P1Y2M") returns 14
months("-P19M") returns -19



prev next


How to be a Smart and Efficient Web Developer?

Use a web development platform that will help you save a lot of time and bring excitement to your daily development work. It will also create professional best-practices around your code development and team collaboration.

Try Springloops now, the web development platform




diploma   

Get Your Diploma!

W3Schools' Online Certification Program is the perfect solution for busy professionals who need to balance work, family, and career building.

The HTML Certificate is for developers who want to document their knowledge of HTML, XHTML, and CSS.

The ASP Certificate is for developers who want to document their knowledge of ASP, SQL, and ADO.



Jump to: Top of Page or HOME or Printer Friendly Printer friendly page

W3Schools provides material for training only. We do not warrant the correctness of its contents. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.

Copyright 1999-2008 by Refsnes Data. All Rights Reserved.

Validate Validate W3C-WAI level A conformance icon W3Schools was converted to XHTML in December 1999
SITE SEARCH
 
About W3Schools
W3Schools Forum
ASP.NET Web Hosting
ASP.NET
Web Hosting
WEB HOSTING
$15 Domain Name
Registration
Save $20 / year!
UK Domain Names
UK Web Hosting

Alojamiento Web
Buy UK Domain Names
Register Domain Names
Cheap Domain Names
Cheap Web Hosting
Best Web Hosting
Domain Name Registration
PHP MySQL Hosting
Top 10 Web Hosting
Web Hosting Providers
Web Hosting Company
UK Web Hosting
UK Reseller Hosting
Web Hosting
WEB BUILDING
Website Templates
Flash Templates
Website Builder
Internet Business Opportunity
Custom Programming
FREE Trial or Demo
Web Content Manager
Forms,Web Alerts,RSS
Ecommerce Software
Learn XML with XMLSpy®
Azbuz Blog
SHOPPING
UK Wholesalers
UK Wholesale
UAE Dubai Property
Private Student Loans
UK Dropshippers & Wholesalers Directory
EDUCATION
US Web Design Schools
HTML Exam
YELLOW PAGES
www.nettkatalogen.no
www.gulex.dk
www.gulex.se
www.gelbex.de
www.teloos.fi
www.teloos.fr
www.teloos.co.uk
www.teloos.at
www.teloos.de