# Presentation: 665784

## DoD Per Diem Rates 	with XML Schema

- Ken Sall  _[http://](http://kensall.com/gov/perdiem)__[kensall.com/gov/perdiem](http://kensall.com/gov/perdiem)_
- XML WG Registry and Repository Meeting
- May 21, 2003

## Demo Goals

**Convert ASCII files to XML instances**
**Generate XML Schema based on one instance**
**Refine XML Schema by adding types**
**Validate  instances against XML Schema**
**Use XSLT to convert XML to HTML for display (server-side and client-side)**

## DoD Per Diem Rates Tables

** **

- DoD _[Per Diem Rates ](http://www.dtic.mil/perdiem/pdrates.html)__Tables_

**Available as semi-colon delimited ASCII files**
**Connow.txt - Includes Military Installations; 1136 entries**
**Conusnm.txt - No Military Installations; 690 entries**
**Conusmil.txt - Military Installations only; 446 entries **

## Semi-Colon Delimited ASCII

-  CONUS;ALL PLACES NOT LISTED;(FOR ALASKA & HAWAII SEE APP B);01/01;12/31;55;28;18;85;01/01/2000;
- ALABAMA;ANNISTON ARMY DEPOT;CALHOUN;01/01;12/31;55;28;18;85;01/01/2000;
- ALABAMA;BESSEMER NAVAL & MC RES CTR;JEFFERSON;01/01;12/31;59;40;24;101;10/01/2002;
- ALABAMA;BIRMINGHAM;JEFFERSON;01/01;12/31;59;40;24;101;10/01/2002;
- ALABAMA;DANNELLY FIELD AGS;MONTGOMERY;01/01;12/31;57;40;24;99;10/01/2002;
- ALABAMA;DECATUR;MORGAN;01/01;12/31;69;32;20;103;10/01/2002;
- ALABAMA;FT. MCCLELLAN;CALHOUN;01/01;12/31;55;28;18;85;01/01/2000;
- ALABAMA;FT. RUCKER;DALE;01/01;12/31;55;28;18;85;01/01/2000;
- ALABAMA;GADSDEN NAVAL RESERVE CTR;CALHOUN;01/01;12/31;55;28;18;85;01/01/2000;
- ALABAMA;GULF SHORES;BALDWIN;05/15;09/04;101;36;22;139;10/01/2002;
- ALABAMA;GULF SHORES;BALDWIN;09/05;05/14;64;36;22;102;10/01/2002;
- ALABAMA;HUNTSVILLE;MADISON;01/01;12/31;67;36;22;105;10/01/2002;
- ALABAMA;MAXWELL AFB;MONTGOMERY;01/01;12/31;57;40;24;99;10/01/2002;

## Convert ASCII Files to XML Instances

**XML Spy reads delimited files and lets you assign element names**

## - <PerDiemRates xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PerDiem.xsd">

- -+ <Row>
** ** - <Row>
** ** <State>**ALABAMA**</State>
** ** <LocalityOrCity>**ANNISTON ARMY DEPOT**</LocalityOrCity>
** ** <County>**CALHOUN**</County>
** ** <SeasonBegin>**01/01**</SeasonBegin>
** ** <SeasonEnd>**12/31**</SeasonEnd>
** ** <MaxLodging>**55**</MaxLodging>
** ** <NoGovernmentMeals>**28**</NoGovernmentMeals>
** ** <ProportionalMeals>**18**</ProportionalMeals>
** ** <MaxPerDiemRate>**85**</MaxPerDiemRate>
** ** <EffectiveDate>**01/01/2000**</EffectiveDate>
** ** </Row>
- - <Row>
** ** <State>**ALABAMA**</State>
** ** <LocalityOrCity>**BESSEMER NAVAL & MC RES CTR**</LocalityOrCity>
** ** <County>**JEFFERSON**</County>

## Generate XML Schema

**Based on single XML instance**
**Uses enumerations to constrain numbers**
**Other two instances fail to validate with this generated schema**
**Could prevent the enumerated constraints**

##  <!-- W3C Schema generated by XMLSPY v5 rel. 2 (http://www.xmlspy.com)  --> 

- - <xs:schema xmlns:xs="**http://www.w3.org/2001/XMLSchema**" elementFormDefault="**qualified**">
** ** <xs:element name="**County**" type="**xs:string**" />
- - <xs:element name="**EffectiveDate**">
- - <xs:simpleType>
- - <xs:restriction base="**xs:string**">
** ** <xs:enumeration value="**01/01/1999**" />
** ** <xs:enumeration value="**01/01/2000**" />
** ** <xs:enumeration value="**01/01/2002**" />
** ** <xs:enumeration value="**01/15/2003**" />
** ** <xs:enumeration value="**07/15/2002**" /> ** ** <xs:enumeration value="**07/21/2000**" />
** ** <xs:enumeration value="**09/01/2000**" /> ** ** <xs:enumeration value="**09/01/2002**" />
** ** <xs:enumeration value="**10/01/2000**" /> ** ** <xs:enumeration value="**10/01/2001**" />
** ** <xs:enumeration value="**10/01/2002**" /> ** ** <xs:enumeration value="**11/08/2002**" />
** ** <xs:enumeration value="**12/15/2002**" />
** ** </xs:restriction>
** ** </xs:simpleType>
** ** </xs:element>

## Slide 9

## Slide 10

## Slide 11

## Refine XML Schema	

**Consider all 3 XML instances, looking at range of data**
**Define data types**
- Date formats (not same as xsd:date)
- Restricted integer ranges
**Discovered 4 irregularities in per diem data**
- 3 counties missing (one file had delimiters, one did not)
- 1 rate (out of 1136 times 4) contained decimal value; all others were integers

## - <xs:simpleType name="SeasonType">

- - <xs:restriction base="**xs:string**">
** ** <xs:pattern value="**\d{2}/\d{2}**" />
** ** </xs:restriction>
** ** </xs:simpleType>
- - <xs:simpleType name="**DateType**">
- - <xs:restriction base="**xs:string**">
** ** <xs:pattern value="**\d{2}/\d{2}/\d{4}**" />
** ** </xs:restriction>
** ** </xs:simpleType>
- - <xs:simpleType name="**Under500Type**">
- - <xs:restriction base="**xs:double**">
** ** <xs:minInclusive value="**25**" />
** ** <xs:maxInclusive value="**500**" />
** ** </xs:restriction>
** ** </xs:simpleType>

** **** ****<****xs:element**** ****name****="****MaxPerDiemRate****"**** type****="****Under500Type****" />**

- <xs:element name="**County**" type="**xs:string**" />
** ** <xs:element name="**EffectiveDate**" type="**DateType**" />** **

## Irregular Data – Missing County

## Use XSLT to Display as HTML

## XSLT with Sort by Rate

## Next Steps [Pending GSA Direction]

**Contact DoD about data irregularities**
**Make element names ISO/IEC 11179-compliant**
**Contribute to Registry**
**Consider creating Web services to **
- Retrieve entire table
- Retrieve one entry based on location

## Slide 18