- let formatter = case mType of
- MIMEType "application" "xhtml+xml" _ -> toXHTML
- MIMEType "text" "xml" _ -> this
- _ -> undefined
- [resultStr] <- liftIO $ runX ( setErrorMsgHandler False fail
- >>>
- constA tree
- >>>
- formatter
- >>>
- writeDocumentToString [ (a_indent, v_1) ]
- )
- output resultStr
-
-
-getUserID :: Environment -> Resource (Maybe String)
+ let formatter = case lookup mType formatters of
+ Just f → f
+ Nothing → this
+ [resultStr] ← liftIO $
+ runX ( setErrorMsgHandler False fail
+ >>>
+ constA tree
+ >>>
+ formatter
+ >>>
+ writeDocumentToString
+ [ withIndent yes
+ , withXmlPi yes
+ ]
+ )
+ output $ UTF8.encodeString resultStr
+
+outputXmlPage' :: XmlTree -> IOSArrow XmlTree XmlTree -> Resource ()
+outputXmlPage' tree toXHTML
+ = outputXmlPage tree [(MIMEType "application" "xhtml+xml" [], toXHTML)]
+
+outputXml ∷ XmlTree → Resource ()
+outputXml tree
+ = do setContentType (MIMEType "text" "xml" [])
+ let [xmlStr] = runLA ( writeDocumentToString
+ [ withIndent yes
+ , withXmlPi yes
+ ]
+ ) tree
+ output $ UTF8.encodeString xmlStr
+
+getUserID ∷ Environment → Resource (Maybe String)