190 likes | 265 Views
Lecture 6. Data flows, serial structures, data interchange standards and XML. Service Provider. Consolidator. extract. Schedule data. Validate and load. Consolidated schedules. Fixed Format file. 01 70Centre 1 020720 020740 ..
E N D
Lecture 6 Data flows, serial structures, data interchange standards and XML
Service Provider Consolidator extract Schedule data Validate and load Consolidated schedules
Fixed Format file • 01 70Centre 1 • 020720 • 020740 • .. • 01 99Centre to Blackboy Hill 2 • 020930
Fixed format file definition There are two record types 01 and 02. 01 records define routes, 02 records define departures on the preceding route. 01 Format 1-2 record number ‘01’ 3-6 route number 7-27 destination 28 bay number ( 1-5) 02 Format 1-2 record number ‘02’ 3-4 departure time: hours (24 hour clock – local time) 5-6 departure time : minutes See the atco-cif file definition
META-DATA – data about the data. • File structure • Validation rules • Origination and authorisation • Version
Formal syntax definitions • Enable a process to read the syntax definition, then check a file conforms to the syntax – is ‘well-formed’ • Enable programmers to define transformations of the file into other formats (for XML using XSLT) • Communicates a file definition to writers and readers of the file • Defines the implicit data model
Comma Separated Variable (CSV) Files • 01,70,Centre,1 • 02,07:20 • 02,07:40 • .. • 01,99,Centre to Blackboy Hill, 2 • 02,09:30
Existing File formats • Files from legacy COBOL systems (coded as fixed format records, with no attached meta-data) • BACS files for bank – standard published by the Association for Payment Clearing Services • Image file formats (JPEG,GIF) • Sound files (MP3) • Archived, Compressed files (ZIP) • HTML?
HTML <table border=1><tr><th>Route</th><th>Time</th><th>Destination</th><th>Bay</th></tr><tr><td><a href='http://www.firstcityline.co.uk/tt/070mf.htm '>70</a></td><td>15:24:00</td><td>Centre</td><td>3</td></tr> <tr><td><a href='http://www.firstcityline.co.uk/tt/070mf.htm '>70</a></td><td>15:39:00</td><td>Centre</td><td>3</td></tr>
XML <route> <routeno>99</routeno> <destination>Centre via Blackboy Hill</destination> <bay>2</bay> <departures> <dtime>7:00</dtime> <dtime>7:20</dtime> </departures> </route>
Cascading Style Sheet routeno {display: block; color:red; font-size:400%; } destination {display: block; border-style:double; border-width:thick; color: pink;font-size:200%; } bay {display: none; } dtime {display: table-cell;}
File Route * routeno destination bay departures Dtime * Jackson Structure Diagram
BNF syntax specifiation file = { route } route = routeno destination bay departures departures = {departure} routeno= 2 {char} 3 destination = 5 {char}20 bay = digit departure = dtime dtime = digit digit ':' digit digit digit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' char = letter | digit letter = ‘A’ | ‘B’ | ‘C’ | ‘D’ | ‘E’ | ‘F’ | ‘G’ | ‘H’ | ‘I’ | ‘J’ | ‘K’ | ‘L’ | ‘M’ | ‘N’ | ‘O’ | ‘P’ | ‘Q’ | ‘R’ | ‘S’ | ‘T’ | ‘U’ | ‘V’ | ‘W’ | ‘X’ | ‘Y’ | ‘Z’
Generated random data • 01,E60,ETET NHNXETE,2 • 02,59:39 • 02,19:43 • 02,83:55 • 02,50:27 • 02,70:69 • 02,87:66 • 02,48:21 • 02,93:26 • 02,99:11 • 02,36:20 • 02,13:23
XML DTD for the schedule <!DOCTYPE route [ <!ELEMENT route (routeno,destination,bay,departures)> <!ELEMENT routeno (#PCDATA)> <!ELEMENT destination (#PCDATA)> <!ELEMENT bay (#PCDATA)> <!ELEMENT departures (dtime+) > <!ELEMENT dtime (#PCDATA) > ]>
XSchema definition <?xml version="1.0"?> <xs:element name="route"> <xs:complexType> <xs:sequence> <xs:element name="routeNo" type="xs:string"/> <xs:element name="destination" type="xs:string"/> <xs:element name="bay" type="xs:string"/> <xs:element name="departures"> <xs:complexType> <xs:sequence> <xs:element name="dtime" maxOccurs="unbounded" type="xs:time"/> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
Beyond Syntax • Is this file authorized by the service provider? • How are authorized providers set up within the consolidator? • Which side of the interaction is responsible for initiating the transfer – • the consolidator ( “pull”) • or the service provider (“push”) • Where are pushed files stored before processing? • If there is an error in the file, how is this fact notified to the provider? • What else?
Exercises • Take a look at the BNF sentence generator • Modify my syntax to add the weblink • Look at the atco-cif file spec: • Draw the JSD • Draw the underlying ER model • Look at the TransXchange XSchema