]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - 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
diff --git a/bundles/org.simantics.scl.data/examples/XMLTransformationTest.scl b/bundles/org.simantics.scl.data/examples/XMLTransformationTest.scl
new file mode 100644 (file)
index 0000000..af2a509
--- /dev/null
@@ -0,0 +1,26 @@
+import "Data/XML"\r
+\r
+mapping relation MapNote Element Element\r
+\r
+rule SectionsRule where\r
+    @when\r
+    MapNote ?noteA ?noteB\r
+    ?sectionName <- ["from", "to", "heading", "body"]\r
+    \r
+    @from\r
+    Attribute ?noteA ?sectionName ?text\r
+    \r
+    @to\r
+    Element ?noteB ?sectionName ?el\r
+    TextContent ?el ?text\r
+    \r
+main () = do\r
+    doc = parseString """<note to="Tove" from="Jani" heading="Reminder" body="Don't forget me this weekend!"/>"""\r
+\r
+    doc2 = parseString "<note/>"\r
+\r
+    transformation OneShotForward where\r
+        MapNote (rootElementOf doc) (rootElementOf doc2)\r
+    \r
+    print $ outputString doc2\r
+    
\ No newline at end of file