]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.data/examples/XMLTransformationTest.scl
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.scl.data / examples / XMLTransformationTest.scl
1 import "Data/XML"\r
2 \r
3 mapping relation MapNote Element Element\r
4 \r
5 rule SectionsRule where\r
6     @when\r
7     MapNote ?noteA ?noteB\r
8     ?sectionName <- ["from", "to", "heading", "body"]\r
9     \r
10     @from\r
11     Attribute ?noteA ?sectionName ?text\r
12     \r
13     @to\r
14     Element ?noteB ?sectionName ?el\r
15     TextContent ?el ?text\r
16     \r
17 main () = do\r
18     doc = parseString """<note to="Tove" from="Jani" heading="Reminder" body="Don't forget me this weekend!"/>"""\r
19 \r
20     doc2 = parseString "<note/>"\r
21 \r
22     transformation OneShotForward where\r
23         MapNote (rootElementOf doc) (rootElementOf doc2)\r
24     \r
25     print $ outputString doc2\r
26