@@ -195,28 +195,68 @@ parseList c =
196parseComplexType :: Cursor -> P Xsd.ComplexType
196parseComplexType :: Cursor -> P Xsd.ComplexType
197parseComplexType c = do
197parseComplexType c = do
198− attrAxis <- makeElemAxis "attribute"
199− attributes <- mapM parseAttribute (c $/ attrAxis)
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"
212 annotations <- parseAnnotations c
198 annotations <- parseAnnotations c
213−
199+ cont <- parseContent c
214 return Xsd.ComplexType
200 return Xsd.ComplexType
215− { Xsd.complexAttributes = attributes
216− , Xsd.complexModelGroup = group
217− , Xsd.complexAnnotations = annotations
201+ { Xsd.complexAnnotations = annotations
202+ , Xsd.complexContent = cont
205+parseContent :: Cursor -> P Xsd.Content
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
214+ "Expected one of simpleContent, complextContent or model group"
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
225+parseSimpleContent :: Cursor -> P Xsd.SimpleContent
226+parseSimpleContent c = parseError c "not implemented"
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"
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
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"
220parseSequence :: Cursor -> P Xsd.ModelGroup
260parseSequence :: Cursor -> P Xsd.ModelGroup
221parseSequence c = Xsd.Sequence <$> parseElements c
261parseSequence c = Xsd.Sequence <$> parseElements c
@@ -232,6 +272,11 @@ parseElements c = do
232 elementAxis <- makeElemAxis "element"
272 elementAxis <- makeElemAxis "element"
233 mapM parseElement (c $/ elementAxis)
273 mapM parseElement (c $/ elementAxis)
275+parseAttributes :: Cursor -> P [Xsd.Attribute]
276+parseAttributes c = do
277+ attrAxis <- makeElemAxis "attribute"
278+ mapM parseAttribute (c $/ attrAxis)
235parseAttribute :: Cursor -> P Xsd.Attribute
280parseAttribute :: Cursor -> P Xsd.Attribute
236parseAttribute c = do
281parseAttribute c = do
237 name <- theAttribute "name" c >>= makeTargetQName
282 name <- theAttribute "name" c >>= makeTargetQName