Last active
December 14, 2015 01:18
-
-
Save dpwiz/5004655 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | Little helper to apply default service namespace to a node and it's descendants. | |
-- This removes the necessity to flood your code with {http://vendor.silly.web/Service.spamx} in element names. | |
flowNS :: Maybe Text -> Node -> Node | |
flowNS ns (NodeElement (Element (Name local Nothing prefix) as cs)) = NodeElement $ Element (Name local ns prefix) as $ map (flowNS ns) cs -- update element ns and continue | |
flowNS ns (NodeElement (Element name@(Name _ ns' _) as cs)) = NodeElement $ Element name as $ map (flowNS ns') cs -- switch to new namespace and continue | |
flowNS ns node = node -- ignore non-element nodes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment