Example markup for nested models
Appearance
Describe Example markup for nested models here.
~-
<?xml version="1.0" encoding="utf-8" ?>
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:br="http://www.x-port.net/bindingresolver/"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:sxf="http://www.w3.org/2008/simplexforms"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
<head>
<title>Simple XForms</title>
</head>
<body>
<h1>Example of nested model syntax...</h1>
<!-- consume generic flight info service and adapt to our airline and set defaults
appropriate to common usage, e.g. today's date, our airline, etc -->
<xf:model id="AA_flight_info_service">
<xf:instance id="AA_defaults">
<instanceData xmlns="">
<datename>Today</datename>
<date/>
<departure_city/>
<arrival_city/>
<flight_no/>
<locator_code/>
</instanceData>
</xf:instance>
<!-- set up query parms using context info to simplify data entry from mobile device:
today's date
current location, if available from GPS or other accessible locator info
default carrier
locator code checksum for quick validation -->
<xf:bind nodeset="instance('')/time" calculate="now()" />
<xf:bind nodeset="instance('AA_defaults')/departure_city" calculate="...LatLongToCity(GPScoord())..."/>
<xf:bind nodeset="instance('AA_defaults')/locator_code" constraint="...AA locator checksum..."/>
<xf:bind nodeset="instance('AA_defaults')/date" calculate="...dateFromDatename(../datename)..."/>
<xf:instance id="offered_dates">
<instanceData xmlns="">
<dates>
<date>Today</date>
<date>Tomorrow</date>
<date>Yesterday</date>
</dates>
</instanceData>
</xf:instance>
<xf:instance id="valid_arrival_cities">
<instanceData xmlns="">
<city/> <!-- computed once we have a departure city...looks up AA routes from that city -->
</instanceData>
</xf:instance>
<xf:bind nodeset="arrival_city" relevant="../departure_city <> '' "/>
<!-- add web service lookup for valid arrival cities below... -->
<xf:submission id="AA_query" />
<!-- want to be able to set parms and redirect to submodel submission, maybe after doing our own web service invocation to fill in values... -->
<!-- wire up instance elements in the AA model to the underlying generic query service -->
<!-- start and end dates are the same for the AA service...only does single date query -->
<xf:bind nodeset="instance('query_parms')/start_date" calculate="instance('AA_defaults')/date"/>
<xf:bind nodeset="instance('query_parms')/end_date" calculate="instance('AA_defaults')/date"/>
<!-- time is always set to now() -->
<xf:bind nodeset="instance('query_parms')/time" calculate="now()" />
<!-- airline is always AA -->
<xf:bind nodeset="instance('query_parms')/airline" calculate="AA" />
<!-- would be nice if the following could be "linked" by reference from the AA instance, vs. copied -->
<xf:bind nodeset="instance('query_parms')/departure_city" calculate="instance('AA_defaults')/departure_city" />
<xf:bind nodeset="instance('query_parms')/arrival_city" calculate="instance('AA_defaults')/arrival_city" />
<xf:bind nodeset="instance('query_parms')/flight_no" calculate="instance('AA_defaults')/flight_no" />
<xf:bind nodeset="instance('query_parms')/locator" calculate="instance('AA_defaults')/locator" />
<!------------------------------->
<!-- this model corresponds to a generic flight info web service -->
<xf:model id="flight_info_service">
<xf:instance id="query_parms">
<instanceData xmlns="">
<start_date/> <!-- start date for flight queries, required -->
<end_date/> <!-- end date for flight queries, required -->
<time/> <!-- if provided, find flights near this time -->
<airline/> <!-- required -->
<departure_city/> <!-- one of departure city or arrival city must be filled in if locator_code and flight_no are blank -->
<arrival_city/>
<locator_code/> <!-- if provided, search for flights in this specific reservation -->
<flight_no/> <!-- if provided, override time preference -->
</instanceData>
</xf:instance>
<xf:instance id="search_results">
<flights>
<flight_no/>
<departure_datetime/> <!-- ISO datetime -->
<arrival_datetime/> <!-- ISO datetime -->
<departure_city/>
<arrival_city/>
</flights>
</xf:instance>
<xf:submission id="submit1" method="..." action="..." />
</xf:model>
</xf:model>
<!-- model as generated -->
<!-- UI using generated model -->
<xf:group model="AA_flight_info_service">
<xf:input ref="departure_city">
<xf:label>Departure City:</xf:label>
</xf:input>
<xf:select1 ref="instance('AA_flight_info_service')/arrival_city">
<xf:label>Arrival City:</xf:label>
<xf:itemset nodeset="instance('valid_arrival_cities')/city">
<xf:label ref="."/>
<xf:value ref="."/>
</xf:itemset>
</xf:select1>
<xf:select1 ref="instance('AA_flight_info_service')/datename">
<xf:label>Date</xf:label>
<xf:itemset nodeset="instance('offered_dates')/date">
<xf:label ref="."/>
<xf:value ref="."/>
</xf:itemset>
</xf:select1>
<xf:submit submission="AA_query">
<xf:label>Search</xf:label>
</xf:submit>
</xf:group>
</body>
</html>
-~