]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.data/examples/XMLTransformationTest2.scl
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.scl.data / examples / XMLTransformationTest2.scl
1 import "Data/XML"
2
3 sexOfRole "father"   = "Male"
4 sexOfRole "mother"   = "Female"
5 sexOfRole "son"      = "Male"
6 sexOfRole "daughter" = "Female"
7
8 mapping relation RootMapping Element Element
9
10 rule PersonRule where
11     @when
12     RootMapping ?families ?persons
13     
14     @from
15     Element ?families "Family" ?family
16     Attribute ?family "lastName" ?lastName
17     Element ?family ?role ?familyMember
18     Attribute ?familyMember "firstName" ?firstName
19     
20     @to
21     Element ?persons (sexOfRole ?role) ?person
22     Attribute ?person "fullName" (?firstName + " " + ?lastName)
23     
24 main :: [String] -> <Proc> ()
25 main [fileName] = do
26     doc = parseFile fileName
27     doc2 = parseString "<Persons/>"
28
29     transformation OneShotForward where
30         RootMapping (rootElementOf doc) (rootElementOf doc2)
31     
32     print $ outputString doc2