@@ -0,0 +1,101 @@
1+-- This file was generated by xsd-isogen version 0.1.0.0
2+-- https://github.com/dredozubov/xsd-isogen
3+
4+{-# OPTIONS_GHC -Wno-unused-imports #-}
5+module Dummy where
6+
7+import Control.DeepSeq
8+import Data.Scientific
9+import Data.THGen.XML
10+import Text.XML.DOM.Parser
11+import Text.XML.Writer
12+import Text.XML.ParentAttributes
13+import Prelude hiding ((*), (+))
14+
15+
16+{-|
17+Generated from: X
18+-}
19+"X" =:= record ParserAndGenerator
20+ ! "s" [t|Text|]
21+
22+{-|
23+Generated from: A
24+-}
25+"A" =:= record ParserAndGenerator
26+ ! "s" [t|Text|]
27+ ! "x" [t|XmlX|]
28+ ! "i" [t|Integer|]
29+
30+{-|
31+Generated from: B
32+-}
33+"B" =:= record ParserAndGenerator
34+ ! "s" [t|Text|]
35+
36+{-|
37+Generated from: C
38+-}
39+"C" =:= record ParserAndGenerator
40+ ! "s" [t|Text|]
41+ ! "x" [t|XmlX|]
42+
43+data AnyXmlC
44+ = TheXmlC !XmlC
45+ | TheXmlA !XmlA
46+ deriving (Eq, Show)
47+
48+instance NFData AnyXmlC where
49+ rnf = rwhnf
50+
51+instance FromDom AnyXmlC where
52+ fromDom = do
53+ tp <- parseAttribute
54+ (matchName "{http://www.w3.org/2001/XMLSchema-instance}type")
55+ Right
56+ case tp of
57+ "C" -> TheXmlC <$> fromDom
58+ "A" -> TheXmlA <$> fromDom
59+ _ -> throwParserError (PEOther "Unexpected type")
60+
61+instance ToXML AnyXmlC where
62+ toXML (TheXmlC a) = toXML a
63+ toXML (TheXmlA a) = toXML a
64+
65+instance ToXmlParentAttributes AnyXmlC where
66+ toXmlParentAttributes (TheXmlC a) =
67+ ("{http://www.w3.org/2001/XMLSchema-instance}type", "C")
68+ : toXmlParentAttributes a
69+ toXmlParentAttributes (TheXmlA a) =
70+ ("{http://www.w3.org/2001/XMLSchema-instance}type", "A")
71+ : toXmlParentAttributes a
72+data AnyXmlB
73+ = TheXmlB !XmlB
74+ | TheAnyXmlC !AnyXmlC
75+ deriving (Eq, Show)
76+
77+instance NFData AnyXmlB where
78+ rnf = rwhnf
79+
80+instance FromDom AnyXmlB where
81+ fromDom = do
82+ tp <- parseAttribute
83+ (matchName "{http://www.w3.org/2001/XMLSchema-instance}type")
84+ Right
85+ case tp of
86+ "B" -> TheXmlB <$> fromDom
87+ "C" -> TheAnyXmlC <$> fromDom
88+ _ -> throwParserError (PEOther "Unexpected type")
89+
90+instance ToXML AnyXmlB where
91+ toXML (TheXmlB a) = toXML a
92+ toXML (TheAnyXmlC a) = toXML a
93+
94+instance ToXmlParentAttributes AnyXmlB where
95+ toXmlParentAttributes (TheXmlB a) =
96+ ("{http://www.w3.org/2001/XMLSchema-instance}type", "B")
97+ : toXmlParentAttributes a
98+ toXmlParentAttributes (TheAnyXmlC a) =
99+ ("{http://www.w3.org/2001/XMLSchema-instance}type", "C")
100+ : toXmlParentAttributes a
101+