w3schools
Search W3Schools :  
  
HOME HTML CSS XML JAVASCRIPT ASP PHP SQL MORE...   References Examples Forum About

XForms Functions

« Previous Next Chapter »

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


« Previous Next Chapter »


Altova® XMLSpy® - The industry-leading XML editor!

Altova XMLSpy

Whether you're new to XML or already an advanced user, the user-friendly views and powerful entry helpers, wizards, and debuggers in XMLSpy are designed to meet your XML and Web development needs from start to finish.

  • XML editor
  • Graphical XML Schema / DTD editors
  • XSLT 1.0/2.0 editor, debugger, profiler
  • XQuery editor, debugger, profiler
  • XBRL validator & taxonomy editor
  • Support for Office Open XML (OOXML)
  • Graphical WSDL editor & SOAP debugger
  • Java, C#, C++ code generation
  • And much more!

Download a free trial today!

  Altova XMLSpy

WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Top 10 Web Hosting
UK Reseller Hosting
Web Hosting
FREE Web Hosting
Top Web Hosting
Windows Hosting
WEB BUILDING
Download XML editor
FREE Flash Website
FREE Web Templates
Website Monetization
FLIGHT TICKETS
Find the cheapest flight
to any destination now!
EDUCATION
US Web Design Schools
HTML Certification
JavaScript Certification
XML Certification
PHP Certification
ASP Certification
STATISTICS
Browser Statistics
Browser OS
Browser Display
W3Schools.com HOME | TOP | PRINT | FORUM | ABOUT
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.