<?xml version="1.0" encoding="ISO-8859-1"?>
<!--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">-->
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xfm="http://www.w3.org/2002/xforms">
	<meta:meta xmlns:meta="http://www.xsmiles.org/2002/metadata" name="XForms Functions" description="Tests all XForms XPath functions in a single document" />
	<head>
		<link rel="stylesheet" type="text/css" href="xforms.css" />
		<link rel="stylesheet" type="text/css" href="functions.css" />
		<xfm:model id="form1">
			<xfm:submission id="submit1" method="post" action="http://sinex.tml.hut.fi:8080/xforms/request"/>
			<xfm:instance id="instance1" xmlns="">
				<my>
				<items>
				<item><value>100.4</value><name>Item 1</name></item>
				<item><value>-10.4</value><name>Item 2</name></item>
				<item><value>0.4</value><name>Item 3</name></item>
				</items>
				<input>
					<duration>P3DT10H30M1.5S</duration>
					<date>2002-01-01</date>
					<datetime>1970-01-01T01:00:00Z</datetime>
					<string>true</string>
				</input>
				<info>
					<min></min>
					<max></max>
					<sum></sum>
					<nonEmpty></nonEmpty>
					<avg></avg>
					<if></if>
					<now></now>
					<seconds></seconds>
					<months></months>
					<days-from-date></days-from-date>
					<seconds-from-dateTime></seconds-from-dateTime>
					<boolean-from-string></boolean-from-string>
					<version></version>
					<conformance></conformance>
					<current>
						<value>
							<curr>EUR</curr>
							<amt>50</amt>
							<result></result>
						</value>
						<table>
							<value name="USD" value="1.5"/>
							<value name="EUR" value="3.0"/>
						</table>
					</current>
				</info>
				</my>
			</xfm:instance>
			<xfm:bind nodeset="/my/info">
			<xfm:bind nodeset="sum" calculate="sum(/my/items/item/value)"/>
			</xfm:bind>
			<xfm:bind nodeset="info">
			<xfm:bind nodeset="min" calculate="min(/my/items/item/value)"/>
			<xfm:bind nodeset="max" calculate="max(/my/items/item/value)"/>
			<xfm:bind nodeset="avg" calculate="avg(/my/items/item/value)"/>
			<xfm:bind nodeset="nonEmpty" calculate="count-non-empty(/my/items/item/value)"/>
			<xfm:bind nodeset="if" calculate="if(/my/items/item[1]/value=/my/items/item[2]/value,'match','nomatch')"/>
			<xfm:bind nodeset="now" calculate="now()"/>
			<xfm:bind nodeset="seconds" calculate="seconds(/my/input/duration)"/>
			<xfm:bind nodeset="months" calculate="months(/my/input/duration)"/>
			<xfm:bind nodeset="days-from-date" calculate="days-from-date(/my/input/date)"/>
			<xfm:bind nodeset="boolean-from-string" calculate="boolean-from-string(/my/input/string)"/>
			<xfm:bind nodeset="seconds-from-dateTime" 
				calculate="seconds-from-dateTime(/my/input/datetime)"/>
			<xfm:bind nodeset="version" calculate="property('version')"/>
			<xfm:bind nodeset="conformance" calculate="property('conformance-level')"/>
			<xfm:bind nodeset="current/value/result" calculate="../amt * /my/info/current/table/value[@name=current()/../curr]/@value"/>
			</xfm:bind>
			-->
		</xfm:model>
	</head>
	<body>
	<h1>XForms functions</h1>
		<p>
			<xfm:input ref="/my/items/item[1]/value" >
				<xfm:label>Value 1</xfm:label>
			</xfm:input >
		</p>
		<p>
			<xfm:input ref="/my/items/item[2]/value" >
				<xfm:label>Value 2</xfm:label>
			</xfm:input >
		</p>
		<p>
			<xfm:input ref="/my/items/item[3]/value">
				<xfm:label>Value 3</xfm:label>
			</xfm:input >
		</p>
		<p>
			<xfm:input ref="/my/input/duration">
				<xfm:label>Duration value</xfm:label>
			</xfm:input >
		</p>
		<p>
			<xfm:input ref="/my/input/date">
				<xfm:label>Date value</xfm:label>
			</xfm:input >
		</p>
		<p>
			<xfm:input ref="/my/input/datetime">
				<xfm:label>DateTime value</xfm:label>
			</xfm:input >
		</p>		 	
		
		<h2>Function results</h2>
		<p/>
		<p>
			<xfm:output ref="/my/info/min" >
				<xfm:label >min(value)</xfm:label>
			</xfm:output>
		</p>
		<p>
			<xfm:output ref="/my/info/max" >
				<xfm:label >max(value)</xfm:label>
			</xfm:output>
		</p>
		<p>
			<xfm:output ref="/my/info/sum" >
				<xfm:label >sum(value)</xfm:label>
			</xfm:output>
		</p>
		<p>
			<xfm:output ref="/my/info/nonEmpty" >
				<xfm:label >count-non-empty(value)</xfm:label>
			</xfm:output>
		</p>
		<p>
			<xfm:output ref="/my/info/avg" >
				<xfm:label >avg(value)</xfm:label>
			</xfm:output>
		</p>
		<p>
			<xfm:output ref="/my/info/if" >
				<xfm:label >if(value1=value2)</xfm:label>
			</xfm:output>
		</p>
		<p>
			<xfm:output ref="/my/info/seconds	" >
				<xfm:label >seconds()</xfm:label>
			</xfm:output>
		</p>
		<p>
			<xfm:output ref="/my/info/months" >
				<xfm:label >months()</xfm:label>
			</xfm:output>
		</p>
		<p>
			<xfm:output ref="/my/info/days-from-date" >
				<xfm:label >days-from-date()</xfm:label>
			</xfm:output>
		</p>
		<p>
			<xfm:output ref="/my/info/seconds-from-dateTime" >
				<xfm:label >seconds-from-dateTime()</xfm:label>
			</xfm:output>
		</p>
		<p>
			<xfm:output ref="/my/info/version" >
				<xfm:label >property('version')</xfm:label>
			</xfm:output>
		</p>
		<p>
			<xfm:output ref="/my/info/conformance" >
				<xfm:label >property('conformance-level')</xfm:label>
			</xfm:output>
		</p>
		<p>
			<xfm:output ref="/my/info/now" >
				<xfm:label >now()</xfm:label>
			</xfm:output>
		</p>
				<p>
			<xfm:output ref="/my/info/current/value/result" >
				<xfm:label >current() (should be 150)</xfm:label>
			</xfm:output>
		</p>
		<p>
			<xfm:submit>
				<xfm:label>Show instance</xfm:label>
			</xfm:submit>
		</p>
	</body>
</html>
