Title: Xdefinition
1- Xdefinition
- Václav Trojan
- vaclav.trojan_at_syntea.cz
Prague June 25 2005
2Xdefinition description, processing and
transformation of XML data
- Simple intuitive tool for the description of XML
objects - Validation of XML objects
- Possibility to describe processing of XML objects
- Possibility to describe transformation of XML
objects - Easy maintenance of large projects based on XML
objects
Xdefinition is the tool which may supply
technologies like DTD, XML schemas and XSLT
transformations.
3Xdefinition the intuitive way how to describe
XML objects
- ltEmployeegt
- ltPerson FirstName "John"
- LastName "Brown"
- BirthDate "13.7.1971"
- Sex "male"
- Salary "18800" /gt
- ltAddress Street "Small"
- Number "5"
- City "Big"
- State "WonderIsland"
- Zip "12345" /gt
- Good guy.
- lt/Employeegt
4Skeleton of XML helps to design Xdefinition
XML data
- ltPerson FirstName "John"
- LastName "Brown"
- BirthDate "2.8.1975"
- Salary "21700" gt
- Good guy
- lt/Persongt
5References and models of elements
- ltFamilygt
- ltFather Firstname "John"
- Familyname "Smith"
- BirthDate "13.7.1971" /gt
- ltMother Firstname "Jane"
- Familyname "Smith"
- BirthDate "18.9.1972" /gt
- ltSon Firstname "Peter"
- Familyname "Smith"
- BirthDate "18.1.1997" /gt
- ltDaughter Firstname "Mary"
- Familyname "Smith"
- BirthDate "11.12.1998" /gt
- ltAddress Street "Small"
- Number "123"
- City "Big"
- State "WonderIland"
- Zip "56700" /gt
- lt/Familygt
6Sequences
Mixed sequence
- ltFamilygt
- ltFather xdefscript "occurs 0..1 ref
Person" /gt - ltMother xdefscript "occurs 1 ref
Person" /gt - ltxdefmixedgt
- ltSon xdefscript "occurs 0..12 ref
Person" /gt - ltDaughter xdefscript "occurs 0..12 ref
Person" /gt - lt/xdefmixedgt
- ltAddress xdefscript "occurs 1 ref
Address" /gt - lt/Familygt
Choice sequence
ltOwnergt ltxdefchoicegt ltPerson
xdefscript "occurs 1 ref Person" /gt
ltCompany xdefscript "occurs 1 ref Company"
/gt lt/xdefchoicegt ltAddress xdefscript
"occurs 1 ref Address" /gt lt/Ownergt
7Sections of the script validation section of
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 ...
8Example of complete Xdefinition
- ltxdefdef xmlnsxdef "http//www.syntea.cz/xde
f/2.0" - xdefname "Agenda"
- xdefroot "Family Owner Person
Company" - xdefclasses "project.XUtils" gt
- ltPerson Firstname "required string(1,30)"
- Familyname "required string(1,30)"
- Birthdate "required
datetime('d.m.yyyy')" /gt - ltFamilygt
- ltFather xdefscript "occurs 0..1 ref
Person" /gt - ltMother xdefscript "occurs 1 ref
Person" /gt - ltxdefmixedgt
- ltSon xdefscript "occurs 0..12 ref
Person" /gt - ltDaughter xdefscript "occurs 0..12 ref
Person" /gt - lt/xdefmixedgt
- ltAddress xdefscript "occurs 1 ref
Address" /gt - lt/Familygt
9Archives of Xdefinitions
From several Xdefinitions it is possible to
create an archive of many Xdefinitions and it is
possible make cross references between them
ltxdefxar xmlnsxdef "http//www.syntea.cz/xdef/
2.0" gt ltxdefdef xdefname "Family" xdefroot
"Family" gt ltFather xdefscript "occurs
0..1 ref commonPerson" /gt ltMother xdefscript
"occurs 1 ref commonPerson" /gt
ltxdefmixedgt ltSon xdefscript
"occurs 0..12 ref commonPerson" /gt
ltDaughter xdefscript "occurs 0..12 ref
commonPerson" /gt lt/xdefmixedgt ltAddress
xdefscript "occurs 1 ref commonAddress"
/gt lt/xdefdefgt lt-- Models of commonly used
elements --gt ltxdefdef xdefname "common" gt
ltPerson Firstname "required string(1,30)"
Familyname "required string(1,30)"
Birthdate "required datetime('d.m.yyyy')"
/gt ltAddress Street "required
string(1,30)" Number "optional
int()" City "required string()"
State "required string()"
Zip "optional int()" /gt lt/xdefdefgt lt/x
defxargt
10Validation and creation modes
- 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. - 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).
11Example of creation mode
Required result
Input data
ltContract processedDate "200402051400"
conractId "0123456789" gt ltOwner
comanyId "12345678" name
"Firma XYZ" /gt ltHolder personalId
"311270/1234" firstname "John"
lastname "Smith" /gt ltPolicyholder
companyId "87654321" Name
"John Smith" /gt lt/Contractgt
ltContract num "0123456789"gt ltClient role
"1" name "Firma XYZ"
companyId "12345678" /gt ltClient role
"2" firstname "John"
familyname "Smith" personalId
"311270/1234" /gt ltClient role "3"
firstname "Frantisek"
familyname "Novak" personalId
"311270/1234" companyId "87654321"
/gt lt/Contractgt
12Combination of both modes
Input data
ltWeather date "2005-05-11" gt ltMeasurement
wind "5.3" temperature "13.0" time "0500"
/gt ltMeasurement wind "7.2" temperature
"15.2" time "1100" /gt ltMeasurement wind
"8.7" temperature "18.1" time "1500" /gt
ltMeasurement wind "3.9" temperature "16.5"
time "2000" /gt lt/Weathergt
Xdefinition
ltxdefdef xmlnsxdef "http//www.syntea.cz/xdef
/2.0" xdefname "WeatherDisplay"
xdefroot "Weather" gt ltxdefvariablegt
float sum 0 int n 0 lt/xdefvariablegt lthtm
lgtltbodygt lth1gt ltxdeftext xdefscript"create
'Weather on ' from('/Weather_at_date')" /gt
lt/h1gt ltli xdefscript "occurs 1.. create
from('/Weather/Measurement')" gt ltxdeftext
xdefscript "create 'Time '
toString(from('_at_time'))
', wind ' toString(from('_at_wind'))
',
temperature '
toString(from('_at_temperature'))" /gt" lt/ligt
ltxdeftext xdefscript "create 'Average
temprerature '
(ngt0 ? toString(sum/n) 'Not measured')"
/gt lt/bodygtlt/htmlgt ltWeather xdefscript
"finally setElement(compose('html'))"
date "optional string()" gt
ltMeasurement wind "required float()"
temperature "required float(-30.0,
50.0) onTrue
n sum parseInteger(getText())"
time "required
datetime('HHmm')" xdefscript
"occurs 1.." /gt lt/Weathergt lt/xdefdefgt
13Result from previous slide
lthtmlgt ltbodygt lth1gtWeather on
2005-05-11lt/h1gt ltligtTime 0500, wind 5.3,
temperature 13.0lt/ligt ltligtTime 1100, wind
7.2, temperature 15.2lt/ligt ltligtTime 1500,
wind 8.7, temperature 18.1lt/ligt ltligtTime
2000, wind 3.9, temperature 16.5lt/ligt Average
temprerature 15.7 lt/bodygt lt/htmlgt
14(No Transcript)