--- /dev/null
+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