git.iko.soy/typeable/xsd-parser
on master help sign in
Do not fail during seat_map parsing
commit1c51bb1e7dc76546ef8ac8ce44fc5320f39c7a37 authorDenis Redozubov <denis.redozubov@gmail.com> dateFri 4 Oct 2019, 16:38 (7 years ago) parent88420db
1 file changed+18−13
src/Text/XSD/Parser.hs+18−13
src/Text/XSD/Parser.hs+18−13
@@ -105,10 +105,15 @@ toElem cursor = do
105105 datatypeRef <- case mAttrType of
106106 Just dtn -> pure $ DatatypeRef dtn
107107 Nothing -> do
108− case safeHead (cursor $// anyElement) of
109− Just c -> InlineComplex <$> toDatatype c
110− Nothing ->
111− throwXsd $ "[toElem] unexpected children of " <> T.unpack name
108+ let complexType = cursor $// laxElement "complexType"
109+ if P.null complexType
110+ then throwXsd $ "No datatype definition found for element: " <> name
111+ else do
112+ childCursor <- maybeThrowXsd (safeHead complexType)
113+ $ "More than one xs:complexType tag in: " <> show cursor
114+ let name = safeHead $ childCursor $| attribute "name"
115+ InlineComplex . TypeComplex . ComplexType name CTSequence
116+ <$> toElemsAndDatatypes childCursor
112117 pure $ XSD.Element
113118 { name = (ns, name)
114119 , xtype = datatypeRef }
@@ -116,15 +121,15 @@ toElem cursor = do
116121 e ->
117122 throwXsd $ "[toElem] element expected, got: " <> show e
118123
119−toDatatype :: Cursor -> XSDMonad Datatype
120−toDatatype cursor = do
121− case node cursor of
122− NodeElement el -> case nameLocalName (elementName el) of
123− "simpleType" -> TypeSimple <$> toSimpleType cursor
124− "complexType" -> TypeComplex <$> toComplexType cursor
125− e -> throwXsd $ "[toDatatype] xsd node not supported: " <> show e
126− e ->
127− throwXsd $ "[toDatatype] element expected, got: " <> show e
124+-- toDatatype :: Cursor -> XSDMonad Datatype
125+-- toDatatype cursor = do
126+-- case node cursor of
127+-- NodeElement el -> case nameLocalName (elementName el) of
128+-- "simpleType" -> TypeSimple <$> toSimpleType cursor
129+-- "complexType" -> TypeComplex <$> toComplexType cursor
130+-- e -> throwXsd $ "[toDatatype] xsd node not supported: " <> show e
131+-- e ->
132+-- throwXsd $ "[toDatatype] element expected, got: " <> show e
128133
129134toSimpleType :: Cursor -> XSDMonad SimpleType
130135toSimpleType cursor = do