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