topical media & game development

talk show tell print

professional-xml-23-syntax-constraint.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:ev="http://www.w3.org/2001/xml-events"
    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: Constraint</title>
      <xf:model>
        <xf:instance>
          <ex:dateRange>
            <ex:startDate xsi:type="xs:date"/>
            <ex:endDate xsi:type="xs:date" />
            <ex:days xsi:type="xs:integer"/>
          </ex:dateRange>
        </xf:instance>
        <xf:bind nodeset="ex:startDate" required="true()" />
        <xf:bind nodeset="ex:endDate" required="true()" constraint=". &gt; ../ex:startDate" />
        <xf:bind nodeset="ex:days" calculate="days-from-date(../ex:endDate) - days-from-date(../ex:startDate)" readonly="true()" />
        <xf:submission id="submit1" action="http://localhost/work/dump.aspx" />
      </xf:model>
    </head>
    <body>
      <p>
        <xf:input ref="ex:startDate">
          <xf:label>Start Date: </xf:label>
          <xf:message level="ephemeral" ev:event="DOMFocusIn">
          Enter the start date for the report
          </xf:message>
          <xf:setvalue ev:event="xforms-ready">2006-04-01</xf:setvalue>
        </xf:input>
        <xf:input ref="ex:endDate">
          <xf:label>End Date: </xf:label>
          <xf:message level="ephemeral" ev:event="DOMFocusIn">
          Enter the end date for the report
          </xf:message>
        </xf:input><br />
        <xf:output ref="ex:days">
          <xf:label>Days: </xf:label>
        </xf:output>
        <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.