topical media & game development
professional-xml-23-syntax-modelitem.xml / xml
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ex="someURI">
<head>
<title>Model Item Properties</title>
<xf:model>
<xf:instance>
<ex:data>
<ex:item>
<ex:price xsi:type="xs:decimal"/>
<ex:qty xsi:type="xs:integer">1</ex:qty>
<ex:discount xsi:type="xs:decimal"/>
<ex:total xsi:type="xs:decimal"/>
</ex:item>
</ex:data>
</xf:instance>
<xf:bind nodeset="ex:item/ex:price" required="true()" />
<xf:bind nodeset="ex:item/ex:qty" required="true()" />
<xf:bind nodeset="ex:item/ex:discount" relevant="../ex:price*../ex:qty > 100" calculate="../ex:price*../ex:qty*0.1" readonly="true()" />
<xf:bind nodeset="ex:item/ex:total" readonly="true()" calculate="((../ex:price * ../ex:qty)-../ex:discount)" />
</xf:model>
</head>
<body>
<p>
<xf:input ref="ex:item/ex:price">
<xf:label>Price: </xf:label>
</xf:input><br />
<xf:input ref="ex:item/ex:qty">
<xf:label>Quantity: </xf:label>
</xf:input><br />
<xf:output ref="ex:item/ex:discount">
<xf:label>Less discount: </xf:label>
</xf:output><br />
<xf:output ref="ex:item/ex:total">
<xf:label>Total: </xf:label>
</xf:output><br />
<br/>
</p>
</body>
</html>
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.