Good guy.
optional Name of element Name of inner element Attribute name Script Special element xdef:text">
Good guy.
optional Name of element Name of inner element Attribute name Script Special element xdef:text">

Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Xdefinition ® Václav Trojan Prague June 25 2005.

Similar presentations


Presentation on theme: "1 Xdefinition ® Václav Trojan Prague June 25 2005."— Presentation transcript:

1 1 Xdefinition ® Václav Trojan vaclav.trojan@syntea.cz Prague June 25 2005

2 2 Xdefinition ® – description, processing and transformation of XML data n Simple intuitive tool for the description of XML objects n Validation of XML objects n Possibility to describe processing of XML objects n Possibility to describe transformation of XML objects n Easy maintenance of large projects based on XML objects Xdefinition ® is the tool which may supply technologies like DTD, XML schemas and XSLT transformations.

3 3 Xdefinition ® – the intuitive way how to describe XML objects <Person FirstName = "John" LastName = "Brown" BirthDate = "13.7.1971" Sex = "male" Salary = "18800" /> <Address Street = "Small" Number = "5" City = "Big" State = "WonderIsland" Zip = "12345" /> Good guy. <Person FirstName = "required string(1,30)" LastName = "required string(1,30)" BirthDate = "required datetime(' d.M.yyyy')“ Sex = "required list('male','female')" Salary = "optional int()" /> <Address Street = "optional string(1,100)" Number = "required int()" City = "required string(1,30)" State = "required string(1,30)" Zip = "required num()" /> optional Name of element Name of inner element Attribute name Script Special element xdef:text

4 4 Skeleton of XML – helps to design Xdefinition ® <Person FirstName = "John" LastName = "Brown" BirthDate = "2.8.1975" Salary = "21700" > Good guy XML data: <Person FirstName = "required string(1,30)" LastName = "required string(1,30)" BirthDate = "required datetime('d.M.yyyy')" Salary = "required int(1000,100000)"> optional string() Xdefinition ® - empty data fields are replaced by script: <Person FirstName = "" LastName = "" BirthDate = "" Salary = ""> Skeleton - all data values are removed:

5 5 References and models of elements <Father Firstname = "John" Familyname = "Smith" BirthDate = "13.7.1971" /> <Mother Firstname = "Jane" Familyname = "Smith" BirthDate = "18.9.1972" /> <Son Firstname = "Peter" Familyname = "Smith" BirthDate = "18.1.1997" /> <Daughter Firstname = "Mary" Familyname = "Smith" BirthDate = "11.12.1998" /> <Address Street = "Small" Number = "123" City = "Big" State = "WonderIland" Zip = "56700" /> <Person Firstname = "required string(1,30)" Familyname = "required string(1,30)" Birthdate = "required datetime('d.m.yyyy')" /> Rererences points to “models” of elements:

6 6 Sequences Mixed sequence Choice sequence

7 7 Sections of the script – validation section of text values 1. of occurrence of text values (atributes or text values): 1. Description of occurrence of text values (atributes or text values): required value is required optional value is optional ignore value is ignored by program illegal value is illegal (the behaviour is similar as if object was not declared) fixed e value has a fixed form given by the string constant expression “e” (if the value is not present in the input data object it will be created) 2. Few examples of the description of the type of value (“check” methods): string() string of characters int() integer number float() float number boolean() boolean value (“true” or “false”) datetime() date and/or time list() list of values regex() value suits the given regular expression... 3. Actions associated with the validation: onTrue the script code is called if the check method returns “true” onFalse the script code is called if the check method returns “false” Example of a validation section: Salary = "required int(1000,100000); onTrue outln('Salary is OK'); onFalse outln('Salary is out of limits')"

8 8 Example of complete Xdefinition ® <xdef:def xmlns:xdef = "http://www.syntea.cz/xdef/2.0"http://www.syntea.cz/xdef xdef:name = "Agenda" xdef:root = "Family | Owner | Person | Company" xdef:classes = "project.XUtils" > <Person Firstname = "required string(1,30)" Familyname = "required string(1,30)" Birthdate = "required datetime('d.m.yyyy')" /> <Address Street = "required string(1,30)" Number = "optional int()" City = "required string()" State = "required string()" Zip = "optional int()" />

9 9 Archives of Xdefinitions ® From several Xdefinitions it is possible to create an archive of many Xdefinitions and it is possible make cross references between them: http://www.syntea.cz/xdef <Person Firstname = "required string(1,30)" Familyname = "required string(1,30)" Birthdate = "required datetime('d.m.yyyy')" /> <Address Street = "required string(1,30)" Number = "optional int()" City = "required string()" State = "required string()" Zip = "optional int()" />

10 10 Validation and creation modes n The validation mode processes XML data and applies Xdefinition to processed objects. In this mode the process is controlled by input data. Validation mode is used for data validation and for sequential processing of large XML data files. n The creation mode is controlled by the Xdefinition and composes an XML object as a result according to instructions from the Xdefinition. For each object it is invoked the action “create”. Creation mode is useful for XML transformations or for generation of XML data from other resources. Both modes are possible to combine (from validation mode it is possible to invoke creation mode (with the inline method “ compose ”).

11 11 Example of creation mode <Client role = "1" name = "Firma XYZ" companyId = "12345678" /> <Client role = "2" firstname = "John" familyname = "Smith" personalId = "311270/1234" /> <Client role = "3" firstname = "Frantisek" familyname = "Novak" personalId = "311270/1234" companyId = "87654321" /> Input data: Required result: <Contract processedDate = "200402051400" conractId = "0123456789" > <Owner comanyId = "12345678" name = "Firma XYZ" /> <Holder personalId = "311270/1234" firstname = "John" lastname = "Smith" /> <Policyholder companyId = "87654321" Name = "John Smith" /> <Contract processedDate = "required; create toString(now(),'yyyyMMddHHmm')" conractId = "required num(10) create from('@num')> <Owner xdef:script = "occurs 1; create from('Client[@role=\'1\']')" companyId = "required num(8); create from('@companyId')" name = "required string(1,30); create from('@name')" /> <Holder xdef:script = "occurs 1; create from('Client[@role=\'2\']')" personalId = "required string(10,11); create from('@personalId')" firstname = "required string(1,30); create from('@firstname')" lastname = "required string(1,30); create from('@lastname')" /> <Poolicyholder xdef:script = "occurs 1; create from(‘client[@role=\'3\']')" companyId = "required num(8); create from('@ic')" Name = "required string(1,30); create toString(from('@firstname')) + ' ' + from('@lastname')" /> Xdefinition:

12 12 Combination of both modes Input data: <xdef:def xmlns:xdef = "http://www.syntea.cz/xdef/2.0" xdef:name = "WeatherDisplay" xdef:root = "Weather" > float $sum = 0; int $n = 0; <xdef:text xdef:script = "create 'Time: ' + toString(from('@time')) + ', wind: ' + toString(from('@wind')) + ', temperature: ' + toString(from('@temperature'))" />" <xdef:text xdef:script = "create 'Average temprerature: ' + ($n>0 ? toString($sum/$n) : 'Not measured')" /> <Weather xdef:script = "finally setElement(compose('html'))" date = "optional string()" > <Measurement wind = "required float()" temperature = "required float(-30.0, 50.0); onTrue {$n++; $sum += parseInteger(getText());}" time = "required datetime('HH:mm')" xdef:script = "occurs 1.." /> Xdefinition:

13 13 Result from previous slide Weather on 2005-05-11 Time: 05:00, wind: 5.3, temperature: 13.0 Time: 11:00, wind: 7.2, temperature: 15.2 Time: 15:00, wind: 8.7, temperature: 18.1 Time: 20:00, wind: 3.9, temperature: 16.5 Average temprerature: 15.7

14 14


Download ppt "1 Xdefinition ® Václav Trojan Prague June 25 2005."

Similar presentations


Ads by Google