I've just released the first version of text-xml-qq, It's a Template Haskell quasiquoter that converts XML code into Text.XML.Light.Element compile time.
Feature requests, bug fixes etc are welcomed. The package only got one backend (xml-package) at the moment but it should be trivial to add more backends (e.g. for a bytestring-based xml package).
Given the variables
elem = "gmail"
attrNs = "something"
attrName = "Pelle"
attrValue = "Arne"
elemCont = CRef "testing"
cont1 = Elem $ blank_element { elName = QName "hej" Nothing Nothing }
cont2 = CRef "other test"
the code
[$xmlQQ|
<{url}:{elem} {attrNs}:{attrName}={attrValue} attr="cool">
<elem ns1:elem1="1" ns2:elem2="2"><<elemCont>></elem>
<elem />
<el />
<<cont1>>
<<cont2>>
</{url}:{elem}>
|]
will generate the data structure
element {
elName = QName elem Nothing (Just url),
elAttribs = [Attr (QName attrName Nothing (Just attrNs)) attrValue,
Attr (qname "attr") "cool"],
elContent = [
(Elem $ blank_element { elName = QName "elem" Nothing Nothing,
elAttribs = [Attr (QName "elem1" Nothing (Just "ns1")) "1",
Attr (QName "elem2" Nothing (Just "ns2")) "2"],
elContent = [elemCont]
}),
(Elem $ blank_element { elName =QName "elem" Nothing Nothing}),
(Elem $ blank_element { elName = QName "el" Nothing Nothing}),
cont1,
cont2]
}