git.iko.soy/typeable/xsd-parser
on master help sign in
Do not fail during seat_map parsing
1c51bb1Denis Redozubov
src/Text/XSD/Parser.hs+18−13
@@ -105,10 +105,15 @@ toElem cursor = do
105 datatypeRef <- case mAttrType of
105 datatypeRef <- case mAttrType of
106 Just dtn -> pure $ DatatypeRef dtn
106 Just dtn -> pure $ DatatypeRef dtn
107 Nothing -> do
107 Nothing -> do
108− case safeHead (cursor $// anyElement) of
108+ let complexType = cursor $// laxElement "complexType"
109− Just c -> InlineComplex <$> toDatatype c
109+ if P.null complexType
110− Nothing ->
110+ then throwXsd $ "No datatype definition found for element: " <> name
111− throwXsd $ "[toElem] unexpected children of " <> T.unpack 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
112 pure $ XSD.Element
117 pure $ XSD.Element
113 { name = (ns, name)
118 { name = (ns, name)
114 , xtype = datatypeRef }
119 , xtype = datatypeRef }
@@ -116,15 +121,15 @@ toElem cursor = do
116 e ->
121 e ->
117 throwXsd $ "[toElem] element expected, got: " <> show e
122 throwXsd $ "[toElem] element expected, got: " <> show e
118
123
119−toDatatype :: Cursor -> XSDMonad Datatype
124+-- toDatatype :: Cursor -> XSDMonad Datatype
120−toDatatype cursor = do
125+-- toDatatype cursor = do
121− case node cursor of
126+-- case node cursor of
122− NodeElement el -> case nameLocalName (elementName el) of
127+-- NodeElement el -> case nameLocalName (elementName el) of
123− "simpleType" -> TypeSimple <$> toSimpleType cursor
128+-- "simpleType" -> TypeSimple <$> toSimpleType cursor
124− "complexType" -> TypeComplex <$> toComplexType cursor
129+-- "complexType" -> TypeComplex <$> toComplexType cursor
125− e -> throwXsd $ "[toDatatype] xsd node not supported: " <> show e
130+-- e -> throwXsd $ "[toDatatype] xsd node not supported: " <> show e
126− e ->
131+-- e ->
127− throwXsd $ "[toDatatype] element expected, got: " <> show e
132+-- throwXsd $ "[toDatatype] element expected, got: " <> show e
128
133
129toSimpleType :: Cursor -> XSDMonad SimpleType
134toSimpleType :: Cursor -> XSDMonad SimpleType
130toSimpleType cursor = do
135toSimpleType cursor = do