XForms Functions

|  | Search W3Schools : |

HOME | HTML | CSS | XML | JAVASCRIPT | ASP | PHP | SQL | MORE... |  | References | Examples | Forum | About

ADVERTISEMENTS XML Certification Download XML editor Custom Programming |  |

Table of contents

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 Tutorials
W3Schools Forum
Helping W3Schools

# XForms Functions

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

Ektron CMS400.NET Version 7.6 delivers all of the flexibility and features you need to deploy the Web site you want, quickly and efficiently. learn more...

6 ways to take your site to the next level with Ektron:

| Create site stickiness through social networking. Keep it personal, relevant and interactive and they'll come back for more.
| Keep it open. Your site needs to be ready and able to connect to outside services. Ektron's open API gives you maximum flexibility.
| Streamline content and document management. Users need to quickly and intuitively find and add information.
| Empower your content authors. Reduce IT bottlenecks by allowing business users to create and edit Web content and forms.
| Climb to the top of search rankings. SEO tools, URL aliasing and eCommerce for your digital marketing strategy
| Add powerful Web 2.0 tools like blogs, wikis, forums, geo-mapping, rating systems and RSS feeds easily.

See why there are 20,000+ Ektron integrations worldwide. Request an INSTANT DEMO or download a FREE TRIAL today.

WEB HOSTING
Domain Name Registration & More!
$15 Domain Name Registration Save $20 / year!
Buy UK Domain Names Register Domain Names
Cheap Domain Names Cheap Web Hosting
Best Web Hosting
PHP MySQL Hosting
Top 10 Web Hosting
UK Reseller Hosting
Web Hosting
FREE 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
Download XML editor
FREE Flash Website
FREE Web Templates

EDUCATION
US Web Design Schools
HTML Certification
JavaScript Certification
XML Certification
PHP Certification
ASP Certification

HOME or Top of Page |  | Printer Friendly
W3Schools is for training only. We do not warrant the correctness of its content. 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-2009 by Refsnes Data. All Rights Reserved.