git.iko.soy/typeable/xsd-parser
on master help sign in
Default minOccurs and maxOccurs to 1
f9cbe65Denis Redozubov
src/Text/XSD/Internal.hs+2−2
@@ -185,8 +185,8 @@ toQName n =
185data Element = Element
185data Element = Element
186 { name :: !QName
186 { name :: !QName
187 , xtype :: !DatatypeRef
187 , xtype :: !DatatypeRef
188− , minOccurs :: Int
188+ , minOccurs :: !Int
189− , maxOccurs :: (Maybe Int)
189+ , maxOccurs :: !Int
190 , annotations :: [Annotation]
190 , annotations :: [Annotation]
191 } deriving (Show, Eq)
191 } deriving (Show, Eq)
192
192
src/Text/XSD/Parser.hs+4−2
@@ -82,8 +82,10 @@ toElem cursor = do
82 name <- attrThrowXsd "name" el
82 name <- attrThrowXsd "name" el
83 $ "Expected attribute 'name' for element: " <> show (node cursor)
83 $ "Expected attribute 'name' for element: " <> show (node cursor)
84 let
84 let
85+ -- https://www.w3.org/TR/xmlschema-1/#cElement_Declarations
86+ -- https://www.w3.org/TR/xmlschema-1/#declare-element
85− minOc = maybe 0 (read . T.unpack) (M.lookup "minOccurs" attrs)
87+ minOc = maybe 1 (read . T.unpack) (M.lookup "minOccurs" attrs)
86− maxOc = read . T.unpack <$> M.lookup "maxOccurs" attrs
88+ maxOc = maybe 1 (read . T.unpack) (M.lookup "maxOccurs" attrs)
87 datatypeRef <- case mAttrType of
89 datatypeRef <- case mAttrType of
88 Just dtn -> pure $ DatatypeRef dtn
90 Just dtn -> pure $ DatatypeRef dtn
89 Nothing -> do
91 Nothing -> do