@@ -195,28 +195,68 @@ parseList c =
195195
196196parseComplexType :: Cursor -> P Xsd.ComplexType
197197parseComplexType c = do
198− attrAxis <- makeElemAxis "attribute"
199− attributes <- mapM parseAttribute (c $/ attrAxis)
200−
201− group <- do
202− sequenceAxis <- makeElemAxis "sequence"
203− choiceAxis <- makeElemAxis "choice"
204− allAxis <- makeElemAxis "all"
205− case (c $/ sequenceAxis, c $/ choiceAxis, c $/ allAxis) of
206− ([], [], []) -> return Nothing
207− ([g], [], []) -> Just <$> parseSequence g
208− ([], [g], []) -> Just <$> parseChoice g
209− ([], [], [g]) -> Just <$> parseAll g
210− _ -> parseError c "Multiple groups"
211−
212198 annotations <- parseAnnotations c
213−
199+ cont <- parseContent c
214200 return Xsd.ComplexType
215− { Xsd.complexAttributes = attributes
216− , Xsd.complexModelGroup = group
217− , Xsd.complexAnnotations = annotations
201+ { Xsd.complexAnnotations = annotations
202+ , Xsd.complexContent = cont
203+ }
204+
205+parseContent :: Cursor -> P Xsd.Content
206+parseContent c = do
207+ simpleContentAxis <- makeElemAxis "simpleContent"
208+ complexContentAxis <- makeElemAxis "complexContent"
209+ case (c $/ simpleContentAxis, c $/ complexContentAxis) of
210+ ([], []) -> Xsd.ContentPlain <$> parsePlainContent c
211+ ([s], []) -> Xsd.ContentSimple <$> parseSimpleContent s
212+ ([], [s]) -> Xsd.ContentComplex <$> parseComplexContent s
213+ _ -> parseError c
214+ "Expected one of simpleContent, complextContent or model group"
215+
216+parsePlainContent :: Cursor -> P Xsd.PlainContent
217+parsePlainContent c = do
218+ attributes <- parseAttributes c
219+ model <- parseModelGroup c
220+ return Xsd.PlainContent
221+ { Xsd.plainContentModel = model
222+ , Xsd.plainContentAttributes = attributes
223+ }
224+
225+parseSimpleContent :: Cursor -> P Xsd.SimpleContent
226+parseSimpleContent c = parseError c "not implemented"
227+
228+parseComplexContent :: Cursor -> P Xsd.ComplexContent
229+parseComplexContent c = do
230+ restrictionAxis <- makeElemAxis "restriction"
231+ extenstionAxis <- makeElemAxis "extension"
232+ case (c $/ restrictionAxis, c $/ extenstionAxis) of
233+ ([r], []) -> parseError r "not implemented"
234+ ([], [e]) -> Xsd.ComplexContentExtension <$> parseComplexExtension e
235+ _ -> parseError c "Expected one of restriction or extension"
236+
237+parseComplexExtension :: Cursor -> P Xsd.ComplexExtension
238+parseComplexExtension c = do
239+ base <- theAttribute "base" c >>= makeQName c
240+ attributes <- parseAttributes c
241+ model <- parseModelGroup c
242+ return Xsd.ComplexExtension
243+ { Xsd.complexExtensionBase = base
244+ , Xsd.complexExtensionModel = model
245+ , Xsd.complexExtensionAttributes = attributes
218246 }
219247
248+parseModelGroup :: Cursor -> P (Maybe Xsd.ModelGroup)
249+parseModelGroup c = do
250+ sequenceAxis <- makeElemAxis "sequence"
251+ choiceAxis <- makeElemAxis "choice"
252+ allAxis <- makeElemAxis "all"
253+ case (c $/ sequenceAxis, c $/ choiceAxis, c $/ allAxis) of
254+ ([], [], []) -> return Nothing
255+ ([g], [], []) -> Just <$> parseSequence g
256+ ([], [g], []) -> Just <$> parseChoice g
257+ ([], [], [g]) -> Just <$> parseAll g
258+ _ -> parseError c "Multiple model groups"
259+
220260parseSequence :: Cursor -> P Xsd.ModelGroup
221261parseSequence c = Xsd.Sequence <$> parseElements c
222262
@@ -232,6 +272,11 @@ parseElements c = do
232272 elementAxis <- makeElemAxis "element"
233273 mapM parseElement (c $/ elementAxis)
234274
275+parseAttributes :: Cursor -> P [Xsd.Attribute]
276+parseAttributes c = do
277+ attrAxis <- makeElemAxis "attribute"
278+ mapM parseAttribute (c $/ attrAxis)
279+
235280parseAttribute :: Cursor -> P Xsd.Attribute
236281parseAttribute c = do
237282 name <- theAttribute "name" c >>= makeTargetQName