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