Sample DB to XML |
Top Previous Next |
Current XML definition for XML files that can be imported by Crash Magic. The purpose of this section is to document the XML structures used by the converter. Clients should not alter the XML directly. The XML defines how the data is queried and how the generated XML file is defined. All XML files generated by the Crash Magic Converter will begin with "<pdroot>" as the root element.
<DbToXml> <General> <FileRenames> <FileRename>*Incident*=Incident.txt</FileRename> <FileRename>*Unit*=Unit.txt</FileRename> <FileRename>*Person*=Person.txt</FileRename> </FileRenames> <FileChecks> <FileCheck> <FileName>Incident.txt</FileName> <FirstLine>IncidentID,Microfilm,ADOTReceivedDate,Status,DataConv2008Flag,IncidentDate,...</FirstLine> </FileCheck> <FileCheck> <FileName>Unit.txt</FileName> <FirstLine>IncidentID,UnitID,UnitNumber,UnitType,UnitTypeDesc,TravelDirection,TravelDirectionDesc,...</FirstLine> </FileCheck> <FileCheck> <FileName>Person.txt</FileName> <FirstLine>IncidentID,UnitID,UnitNumber,PersonID,PersonNumber,PersonType,ZipCode,Age,Sex,...</FirstLine> </FileCheck> </FileChecks> </General> Exmaple start of the XML file
•FileRenames - (Optional) The connection string(s) in the TableSpecs below this section must specify exact file name(s). For some clients, the filenames may be different / unique in each extract. The FileRenames section provides the ability to rename the files found using wildcards to expected file names. If the file names in the zip file are always the same, then this section is not necessary and may be left blank. oFileRename contains <FileSpec>=<StaticFileName> For example Incident*=Incident.txt will rename any files that start with "Incident" to the name "Incident.txt". In the example above, as long as the word Incident appears anywhere in the file name, it will be renamed to Incident.txt. •FileChecks - (Optional, but recommended) Each FileCheck applies to one of the files in the import. The properties in this section can be used to validate the file prior to attempting the convert to XML process. Any failures here will raise an error before the convert process starts oFileName - This is the name of the file after the FileRenames occur. So this is the name of the file that will be used in the TableSpecs below. It should be a simple file name without a path. oFirstLine - In typical text/CSV files that are used for data transfer, the first line of the file is called a "header" line and contains the names of the field that will be found on following lines. This sequence is critical to Crash Magic's converter. The FileChecks section can be used to validate this header line and make sure that if the field order or fields themselves have not changed. ▪This entry must match the first line of the file being imported exactly. ▪It is case-sensitive and even extra/missing spaces within the line will cause it to fail. ▪The "..." in the example above is just for display purposes in the manual ▪A blank entry will always cause an error to be raised ▪To include an entry without a FirstLine check, the single character asterisk * may be used. This will match any content in the line and will not generate an error. This practice is not recommended if it can be avoided.
This is an example of the error that will be shown upon a FileCheck error
This is an example of a successful start to the import process. Note each of the FileCheck entries indicating each of the files that were checked.
Defining XML structure of the the file to be created. <TableSpecs> <TableSpec> <Name>Accidents</Name> <Primary>True</Primary> <ConnectionString>Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\ImportData; Extended Properties="text;HDR=NO;FMT=Delimited"</ConnectionString> <Login/> <Password/> <RequiredFiles> <RequiredFile>Import schema.ini</RequiredFile> </RequiredFiles> <BaseName>CrashRecord</BaseName> <GroupName/> <ItemName>Environment</ItemName> <UniqueFields> <UniqueField>IncidentID</UniqueField> </UniqueFields> <ChildNames> <ChildName>Vehicles</ChildName> </ChildNames> <QueryLines> <QueryLine>SELECT</QueryLine> <QueryLine>IncidentID,</QueryLine> <QueryLine>IncidentDate,</QueryLine> <QueryLine>IncidentDateTime,</QueryLine> <QueryLine>CollisionManner,</QueryLine> <QueryLine>LightCondition,</QueryLine> <QueryLine>FirstHarmfulEvent,</QueryLine> <QueryLine>FirstHarmfulLocation,</QueryLine> <QueryLine>TotalUnits,</QueryLine> <QueryLine>TotalInjuries,</QueryLine> <QueryLine>TotalFatalities,</QueryLine> <QueryLine>InjurySeverity,</QueryLine> <QueryLine>AlcoholInvolvementFlag,</QueryLine> <QueryLine>DrugInvolvementFlag,</QueryLine> <QueryLine>HazardousFlag,</QueryLine> <QueryLine>HitAndRunFlag,</QueryLine> <QueryLine>Onroad,</QueryLine> <QueryLine>CrossingFeature,</QueryLine> <QueryLine>MPNum,</QueryLine> <QueryLine>CityId,</QueryLine> <QueryLine>CountyId,</QueryLine> <QueryLine>StateId,</QueryLine> <QueryLine>StateCode,</QueryLine> <QueryLine>CountryCode,</QueryLine> <QueryLine>Latitude,</QueryLine> <QueryLine>Longitude,</QueryLine> <QueryLine>IntersectionType,</QueryLine> <QueryLine>JunctionRelation,</QueryLine> <QueryLine>Weather</QueryLine> <QueryLine>FROM CrashEnvironment#txt</QueryLine> <QueryLine>WHERE IncidentDate BETWEEN '1/1/2012' AND '1/15/2012'</QueryLine> <QueryLine>ORDER BY IncidentID</QueryLine> </QueryLines> </TableSpec> Example specification of the primary XML element
TableSpec - Specifies the start of the xml structure that will be created. Name - Name of the of the table specification Primary - Boolean value that indicates if this is the primary XML node. ConnectionString - Defines the connection to the data source. Login - Login name if required by the data source. Password - Password for the login if required by the data source. RequiredFile - Name of and required Utility - Text lines PSRattr for import (In this example a schema.ini file has been added to a Utility -Text line with the name of "Import schema.ini"). BaseName - Starting node of the XML crash record GroupName - Used to define a group of XML nodes for example a value of Vehicles can be used to define a group of Vehicle children records ItemName - The name of the XML node that will contain elements from the select statement. QueryLine - Query to extract records from source. Each field returned from the select statement creates an XML element. UniqueField - The primary identifier for the record. This field will also be used for name of the XML file that is created. ChildName - The TableSpec name of XML children that will be included in the XML file.
|