module InterfaceDTD where

import Text.XML.HaXml.Xml2Haskell
import Text.XML.HaXml.OneOfN
import Char (isSpace)


{-Type decls-}

data Interface = Interface Interface_Attrs
			   Versioninfo Messages (Maybe Manual) [Module] [Option]
	       deriving (Eq,Show)
data Interface_Attrs = Interface_Attrs
    { interfaceName :: String
    , interfaceVersion :: String
    , interfaceAuthor :: String
    , interfaceDesign :: Interface_design
    , interfaceLib :: Interface_lib
    , interfaceInteractive :: Interface_interactive
    } deriving (Eq,Show)
data Interface_design = Interface_design_mono  | 
			Interface_design_color
		      deriving (Eq,Show)
data Interface_lib = Interface_lib_std  | 
		     Interface_lib_rna
		   deriving (Eq,Show)
data Interface_interactive = Interface_interactive_on
			      |  Interface_interactive_off
			   deriving (Eq,Show)
newtype Versioninfo = Versioninfo String 		deriving (Eq,Show)
data Messages = Messages Interactive_welcome
			 Interactive_commandline Interactive_help_header
	      deriving (Eq,Show)
newtype Interactive_welcome = Interactive_welcome String 		deriving (Eq,Show)
newtype Interactive_commandline = Interactive_commandline String 		deriving (Eq,Show)
newtype Interactive_help_header = Interactive_help_header String 		deriving (Eq,Show)
data Manual = Manual (Maybe Synopsis)
		     (Maybe Introduction) (Maybe Examples)
	    deriving (Eq,Show)
newtype Synopsis = Synopsis String 		deriving (Eq,Show)
newtype Introduction = Introduction String 		deriving (Eq,Show)
newtype Examples = Examples String 		deriving (Eq,Show)
data Module = Module
    { moduleName :: String
    , moduleSource :: String
    , moduleAdpc :: String
    , moduleCondition :: String
    , moduleOutput_optimal :: String
    , moduleOutput_subopt_start :: String
    , moduleOutput_subopt :: String
    , moduleOutput_subopt_end :: String
    , moduleMain_name :: String
    } deriving (Eq,Show)
data Option = Option Option_Attrs
		     (OneOf9 Help Longhelp Version Switch Set Switchset File Direct Comment)
		     (Maybe Code) (Maybe Man)
	    deriving (Eq,Show)
data Option_Attrs = Option_Attrs
    { optionSwitch :: String
    , optionArgtext :: (Maybe String)
    , optionText :: String
    } deriving (Eq,Show)
newtype Code = Code String 		deriving (Eq,Show)
newtype Man = Man String 		deriving (Eq,Show)
data Help = Help 		deriving (Eq,Show)
data Longhelp = Longhelp 		deriving (Eq,Show)
data Version = Version 		deriving (Eq,Show)
data Switch = Switch
    { switchVar :: String
    , switchSettext :: String
    , switchInfotext :: String
    , switchDefault :: Switch_default
    } deriving (Eq,Show)
data Switch_default = Switch_default_on  | 
		      Switch_default_off
		    deriving (Eq,Show)
data Set = Set
    { setVar :: String
    , setSettext :: String
    , setInfotext :: String
    , setDefault :: String
    , setDatatype :: Set_datatype
    , setMinval :: (Maybe String)
    , setMaxval :: (Maybe String)
    } deriving (Eq,Show)
data Set_datatype = Set_datatype_int  | 
		    Set_datatype_float  |  Set_datatype_string
		  deriving (Eq,Show)
data Switchset = Switchset
    { switchsetVar :: String
    , switchsetSwvar :: String
    , switchsetSettext :: String
    , switchsetDisabletext :: String
    , switchsetInfotext :: String
    , switchsetDefaultval :: String
    , switchsetDefault :: Switchset_default
    , switchsetDatatype :: Switchset_datatype
    , switchsetMinval :: (Maybe String)
    , switchsetMaxval :: (Maybe String)
    } deriving (Eq,Show)
data Switchset_default = Switchset_default_on  | 
			 Switchset_default_off
		       deriving (Eq,Show)
data Switchset_datatype = Switchset_datatype_int  | 
			  Switchset_datatype_float  | 
			  Switchset_datatype_string
			deriving (Eq,Show)
data File = File
    { fileVar :: String
    } deriving (Eq,Show)
data Direct = Direct 		deriving (Eq,Show)
data Comment = Comment 		deriving (Eq,Show)


{-Instance decls-}

instance XmlContent Interface where
    fromElem (CElem (Elem "interface" as c0):rest) =
	(\(a,ca)->
	   (\(b,cb)->
	      (\(c,cc)->
		 (\(d,cd)->
		    (\(e,ce)->
		       (Just (Interface (fromAttrs as) a b c d e), rest))
		    (many fromElem cd))
		 (many fromElem cc))
	      (fromElem cb))
	   (definite fromElem "<messages>" "interface" ca))
	(definite fromElem "<versioninfo>" "interface" c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem (CString _ s:rest) | all isSpace s = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Interface as a b c d e) =
	[CElem (Elem "interface" (toAttrs as) (toElem a ++
					       toElem b ++ maybe [] toElem c ++
					       concatMap toElem d ++
					       concatMap toElem e))]
instance XmlAttributes Interface_Attrs where
    fromAttrs as =
	Interface_Attrs
	  { interfaceName = definiteA fromAttrToStr "interface" "name" as
	  , interfaceVersion = definiteA fromAttrToStr "interface" "version" as
	  , interfaceAuthor = definiteA fromAttrToStr "interface" "author" as
	  , interfaceDesign = definiteA fromAttrToTyp "interface" "design" as
	  , interfaceLib = definiteA fromAttrToTyp "interface" "lib" as
	  , interfaceInteractive = definiteA fromAttrToTyp "interface" "interactive" as
	  }
    toAttrs v = catMaybes 
	[ toAttrFrStr "name" (interfaceName v)
	, toAttrFrStr "version" (interfaceVersion v)
	, toAttrFrStr "author" (interfaceAuthor v)
	, toAttrFrTyp "design" (interfaceDesign v)
	, toAttrFrTyp "lib" (interfaceLib v)
	, toAttrFrTyp "interactive" (interfaceInteractive v)
	]
instance XmlAttrType Interface_design where
    fromAttrToTyp n (n',v)
	| n==n'     = translate (attr2str v)
	| otherwise = Nothing
      where translate "mono" = Just Interface_design_mono
	    translate "color" = Just Interface_design_color
	    translate _ = Nothing
    toAttrFrTyp n Interface_design_mono = Just (n, str2attr "mono")
    toAttrFrTyp n Interface_design_color = Just (n, str2attr "color")
instance XmlAttrType Interface_lib where
    fromAttrToTyp n (n',v)
	| n==n'     = translate (attr2str v)
	| otherwise = Nothing
      where translate "std" = Just Interface_lib_std
	    translate "rna" = Just Interface_lib_rna
	    translate _ = Nothing
    toAttrFrTyp n Interface_lib_std = Just (n, str2attr "std")
    toAttrFrTyp n Interface_lib_rna = Just (n, str2attr "rna")
instance XmlAttrType Interface_interactive where
    fromAttrToTyp n (n',v)
	| n==n'     = translate (attr2str v)
	| otherwise = Nothing
      where translate "on" = Just Interface_interactive_on
	    translate "off" = Just Interface_interactive_off
	    translate _ = Nothing
    toAttrFrTyp n Interface_interactive_on = Just (n, str2attr "on")
    toAttrFrTyp n Interface_interactive_off = Just (n, str2attr "off")
instance XmlContent Versioninfo where
    fromElem (CElem (Elem "versioninfo" [] c0):rest) =
	(\(a,ca)->
	   (Just (Versioninfo a), rest))
	(definite fromText "text" "versioninfo" c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem (CString _ s:rest) | all isSpace s = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Versioninfo a) =
	[CElem (Elem "versioninfo" [] (toText a))]
instance XmlContent Messages where
    fromElem (CElem (Elem "messages" [] c0):rest) =
	(\(a,ca)->
	   (\(b,cb)->
	      (\(c,cc)->
		 (Just (Messages a b c), rest))
	      (definite fromElem "<interactive_help_header>" "messages" cb))
	   (definite fromElem "<interactive_commandline>" "messages" ca))
	(definite fromElem "<interactive_welcome>" "messages" c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem (CString _ s:rest) | all isSpace s = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Messages a b c) =
	[CElem (Elem "messages" [] (toElem a ++ toElem b ++
				    toElem c))]
instance XmlContent Interactive_welcome where
    fromElem (CElem (Elem "interactive_welcome" [] c0):rest) =
	(\(a,ca)->
	   (Just (Interactive_welcome a), rest))
	(definite fromText "text" "interactive_welcome" c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem (CString _ s:rest) | all isSpace s = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Interactive_welcome a) =
	[CElem (Elem "interactive_welcome" [] (toText a))]
instance XmlContent Interactive_commandline where
    fromElem (CElem (Elem "interactive_commandline" [] c0):rest) =
	(\(a,ca)->
	   (Just (Interactive_commandline a), rest))
	(definite fromText "text" "interactive_commandline" c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem (CString _ s:rest) | all isSpace s = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Interactive_commandline a) =
	[CElem (Elem "interactive_commandline" [] (toText a))]
instance XmlContent Interactive_help_header where
    fromElem (CElem (Elem "interactive_help_header" [] c0):rest) =
	(\(a,ca)->
	   (Just (Interactive_help_header a), rest))
	(definite fromText "text" "interactive_help_header" c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem (CString _ s:rest) | all isSpace s = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Interactive_help_header a) =
	[CElem (Elem "interactive_help_header" [] (toText a))]
instance XmlContent Manual where
    fromElem (CElem (Elem "manual" [] c0):rest) =
	(\(a,ca)->
	   (\(b,cb)->
	      (\(c,cc)->
		 (Just (Manual a b c), rest))
	      (fromElem cb))
	   (fromElem ca))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem (CString _ s:rest) | all isSpace s = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Manual a b c) =
	[CElem (Elem "manual" [] (maybe [] toElem a ++
				  maybe [] toElem b ++ maybe [] toElem c))]
instance XmlContent Synopsis where
    fromElem (CElem (Elem "synopsis" [] c0):rest) =
	(\(a,ca)->
	   (Just (Synopsis a), rest))
	(definite fromText "text" "synopsis" c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem (CString _ s:rest) | all isSpace s = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Synopsis a) =
	[CElem (Elem "synopsis" [] (toText a))]
instance XmlContent Introduction where
    fromElem (CElem (Elem "introduction" [] c0):rest) =
	(\(a,ca)->
	   (Just (Introduction a), rest))
	(definite fromText "text" "introduction" c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem (CString _ s:rest) | all isSpace s = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Introduction a) =
	[CElem (Elem "introduction" [] (toText a))]
instance XmlContent Examples where
    fromElem (CElem (Elem "examples" [] c0):rest) =
	(\(a,ca)->
	   (Just (Examples a), rest))
	(definite fromText "text" "examples" c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem (CString _ s:rest) | all isSpace s = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Examples a) =
	[CElem (Elem "examples" [] (toText a))]
instance XmlContent Module where
    fromElem (CElem (Elem "module" as []):rest) =
	(Just (fromAttrs as), rest)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem (CString _ s:rest) | all isSpace s = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem as =
	[CElem (Elem "module" (toAttrs as) [])]
instance XmlAttributes Module where
    fromAttrs as =
	Module
	  { moduleName = definiteA fromAttrToStr "module" "name" as
	  , moduleSource = definiteA fromAttrToStr "module" "source" as
	  , moduleAdpc = definiteA fromAttrToStr "module" "adpc" as
	  , moduleCondition = definiteA fromAttrToStr "module" "condition" as
	  , moduleOutput_optimal = definiteA fromAttrToStr "module" "output_optimal" as
	  , moduleOutput_subopt_start = definiteA fromAttrToStr "module" "output_subopt_start" as
	  , moduleOutput_subopt = definiteA fromAttrToStr "module" "output_subopt" as
	  , moduleOutput_subopt_end = definiteA fromAttrToStr "module" "output_subopt_end" as
	  , moduleMain_name = definiteA fromAttrToStr "module" "main_name" as
	  }
    toAttrs v = catMaybes 
	[ toAttrFrStr "name" (moduleName v)
	, toAttrFrStr "source" (moduleSource v)
	, toAttrFrStr "adpc" (moduleAdpc v)
	, toAttrFrStr "condition" (moduleCondition v)
	, toAttrFrStr "output_optimal" (moduleOutput_optimal v)
	, toAttrFrStr "output_subopt_start" (moduleOutput_subopt_start v)
	, toAttrFrStr "output_subopt" (moduleOutput_subopt v)
	, toAttrFrStr "output_subopt_end" (moduleOutput_subopt_end v)
	, toAttrFrStr "main_name" (moduleMain_name v)
	]
instance XmlContent Option where
    fromElem (CElem (Elem "option" as c0):rest) =
	(\(a,ca)->
	   (\(b,cb)->
	      (\(c,cc)->
		 (Just (Option (fromAttrs as) a b c), rest))
	      (fromElem cb))
	   (fromElem ca))
	(definite fromElem "OneOf" "option" c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem (CString _ s:rest) | all isSpace s = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Option as a b c) =
	[CElem (Elem "option" (toAttrs as) (toElem a ++
					    maybe [] toElem b ++
					    maybe [] toElem c))]
instance XmlAttributes Option_Attrs where
    fromAttrs as =
	Option_Attrs
	  { optionSwitch = definiteA fromAttrToStr "option" "switch" as
	  , optionArgtext = possibleA fromAttrToStr "argtext" as
	  , optionText = definiteA fromAttrToStr "option" "text" as
	  }
    toAttrs v = catMaybes 
	[ toAttrFrStr "switch" (optionSwitch v)
	, maybeToAttr toAttrFrStr "argtext" (optionArgtext v)
	, toAttrFrStr "text" (optionText v)
	]
instance XmlContent Code where
    fromElem (CElem (Elem "code" [] c0):rest) =
	(\(a,ca)->
	   (Just (Code a), rest))
	(definite fromText "text" "code" c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem (CString _ s:rest) | all isSpace s = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Code a) =
	[CElem (Elem "code" [] (toText a))]
instance XmlContent Man where
    fromElem (CElem (Elem "man" [] c0):rest) =
	(\(a,ca)->
	   (Just (Man a), rest))
	(definite fromText "text" "man" c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem (CString _ s:rest) | all isSpace s = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Man a) =
	[CElem (Elem "man" [] (toText a))]
instance XmlContent Help where
    fromElem (CElem (Elem "help" [] []):rest) =
	(Just Help, rest)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem (CString _ s:rest) | all isSpace s = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem Help =
	[CElem (Elem "help" [] [])]
instance XmlContent Longhelp where
    fromElem (CElem (Elem "longhelp" [] []):rest) =
	(Just Longhelp, rest)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem (CString _ s:rest) | all isSpace s = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem Longhelp =
	[CElem (Elem "longhelp" [] [])]
instance XmlContent Version where
    fromElem (CElem (Elem "version" [] []):rest) =
	(Just Version, rest)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem (CString _ s:rest) | all isSpace s = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem Version =
	[CElem (Elem "version" [] [])]
instance XmlContent Switch where
    fromElem (CElem (Elem "switch" as []):rest) =
	(Just (fromAttrs as), rest)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem (CString _ s:rest) | all isSpace s = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem as =
	[CElem (Elem "switch" (toAttrs as) [])]
instance XmlAttributes Switch where
    fromAttrs as =
	Switch
	  { switchVar = definiteA fromAttrToStr "switch" "var" as
	  , switchSettext = definiteA fromAttrToStr "switch" "settext" as
	  , switchInfotext = definiteA fromAttrToStr "switch" "infotext" as
	  , switchDefault = definiteA fromAttrToTyp "switch" "default" as
	  }
    toAttrs v = catMaybes 
	[ toAttrFrStr "var" (switchVar v)
	, toAttrFrStr "settext" (switchSettext v)
	, toAttrFrStr "infotext" (switchInfotext v)
	, toAttrFrTyp "default" (switchDefault v)
	]
instance XmlAttrType Switch_default where
    fromAttrToTyp n (n',v)
	| n==n'     = translate (attr2str v)
	| otherwise = Nothing
      where translate "on" = Just Switch_default_on
	    translate "off" = Just Switch_default_off
	    translate _ = Nothing
    toAttrFrTyp n Switch_default_on = Just (n, str2attr "on")
    toAttrFrTyp n Switch_default_off = Just (n, str2attr "off")
instance XmlContent Set where
    fromElem (CElem (Elem "set" as []):rest) =
	(Just (fromAttrs as), rest)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem (CString _ s:rest) | all isSpace s = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem as =
	[CElem (Elem "set" (toAttrs as) [])]
instance XmlAttributes Set where
    fromAttrs as =
	Set
	  { setVar = definiteA fromAttrToStr "set" "var" as
	  , setSettext = definiteA fromAttrToStr "set" "settext" as
	  , setInfotext = definiteA fromAttrToStr "set" "infotext" as
	  , setDefault = definiteA fromAttrToStr "set" "default" as
	  , setDatatype = definiteA fromAttrToTyp "set" "datatype" as
	  , setMinval = possibleA fromAttrToStr "minval" as
	  , setMaxval = possibleA fromAttrToStr "maxval" as
	  }
    toAttrs v = catMaybes 
	[ toAttrFrStr "var" (setVar v)
	, toAttrFrStr "settext" (setSettext v)
	, toAttrFrStr "infotext" (setInfotext v)
	, toAttrFrStr "default" (setDefault v)
	, toAttrFrTyp "datatype" (setDatatype v)
	, maybeToAttr toAttrFrStr "minval" (setMinval v)
	, maybeToAttr toAttrFrStr "maxval" (setMaxval v)
	]
instance XmlAttrType Set_datatype where
    fromAttrToTyp n (n',v)
	| n==n'     = translate (attr2str v)
	| otherwise = Nothing
      where translate "int" = Just Set_datatype_int
	    translate "float" = Just Set_datatype_float
	    translate "string" = Just Set_datatype_string
	    translate _ = Nothing
    toAttrFrTyp n Set_datatype_int = Just (n, str2attr "int")
    toAttrFrTyp n Set_datatype_float = Just (n, str2attr "float")
    toAttrFrTyp n Set_datatype_string = Just (n, str2attr "string")
instance XmlContent Switchset where
    fromElem (CElem (Elem "switchset" as []):rest) =
	(Just (fromAttrs as), rest)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem (CString _ s:rest) | all isSpace s = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem as =
	[CElem (Elem "switchset" (toAttrs as) [])]
instance XmlAttributes Switchset where
    fromAttrs as =
	Switchset
	  { switchsetVar = definiteA fromAttrToStr "switchset" "var" as
	  , switchsetSwvar = definiteA fromAttrToStr "switchset" "swvar" as
	  , switchsetSettext = definiteA fromAttrToStr "switchset" "settext" as
	  , switchsetDisabletext = definiteA fromAttrToStr "switchset" "disabletext" as
	  , switchsetInfotext = definiteA fromAttrToStr "switchset" "infotext" as
	  , switchsetDefaultval = definiteA fromAttrToStr "switchset" "defaultval" as
	  , switchsetDefault = definiteA fromAttrToTyp "switchset" "default" as
	  , switchsetDatatype = definiteA fromAttrToTyp "switchset" "datatype" as
	  , switchsetMinval = possibleA fromAttrToStr "minval" as
	  , switchsetMaxval = possibleA fromAttrToStr "maxval" as
	  }
    toAttrs v = catMaybes 
	[ toAttrFrStr "var" (switchsetVar v)
	, toAttrFrStr "swvar" (switchsetSwvar v)
	, toAttrFrStr "settext" (switchsetSettext v)
	, toAttrFrStr "disabletext" (switchsetDisabletext v)
	, toAttrFrStr "infotext" (switchsetInfotext v)
	, toAttrFrStr "defaultval" (switchsetDefaultval v)
	, toAttrFrTyp "default" (switchsetDefault v)
	, toAttrFrTyp "datatype" (switchsetDatatype v)
	, maybeToAttr toAttrFrStr "minval" (switchsetMinval v)
	, maybeToAttr toAttrFrStr "maxval" (switchsetMaxval v)
	]
instance XmlAttrType Switchset_default where
    fromAttrToTyp n (n',v)
	| n==n'     = translate (attr2str v)
	| otherwise = Nothing
      where translate "on" = Just Switchset_default_on
	    translate "off" = Just Switchset_default_off
	    translate _ = Nothing
    toAttrFrTyp n Switchset_default_on = Just (n, str2attr "on")
    toAttrFrTyp n Switchset_default_off = Just (n, str2attr "off")
instance XmlAttrType Switchset_datatype where
    fromAttrToTyp n (n',v)
	| n==n'     = translate (attr2str v)
	| otherwise = Nothing
      where translate "int" = Just Switchset_datatype_int
	    translate "float" = Just Switchset_datatype_float
	    translate "string" = Just Switchset_datatype_string
	    translate _ = Nothing
    toAttrFrTyp n Switchset_datatype_int = Just (n, str2attr "int")
    toAttrFrTyp n Switchset_datatype_float = Just (n, str2attr "float")
    toAttrFrTyp n Switchset_datatype_string = Just (n, str2attr "string")
instance XmlContent File where
    fromElem (CElem (Elem "file" as []):rest) =
	(Just (fromAttrs as), rest)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem (CString _ s:rest) | all isSpace s = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem as =
	[CElem (Elem "file" (toAttrs as) [])]
instance XmlAttributes File where
    fromAttrs as =
	File
	  { fileVar = definiteA fromAttrToStr "file" "var" as
	  }
    toAttrs v = catMaybes 
	[ toAttrFrStr "var" (fileVar v)
	]
instance XmlContent Direct where
    fromElem (CElem (Elem "direct" [] []):rest) =
	(Just Direct, rest)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem (CString _ s:rest) | all isSpace s = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem Direct =
	[CElem (Elem "direct" [] [])]
instance XmlContent Comment where
    fromElem (CElem (Elem "comment" [] []):rest) =
	(Just Comment, rest)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem (CString _ s:rest) | all isSpace s = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem Comment =
	[CElem (Elem "comment" [] [])]


{-Done-}
