git.iko.soy/typeable/xsd-parser
on master help sign in
Default minOccurs and maxOccurs to 1
commitf9cbe65a9b9c37e9015a73707f1cd4f00e79c96e authorDenis Redozubov <denis.redozubov@gmail.com> dateMon 11 Nov 2019, 19:51 (7 years ago) parent1f089fb
2 files changed+6−4
src/Text/XSD/Internal.hs+2−2 src/Text/XSD/Parser.hs+4−2
src/Text/XSD/Internal.hs+2−2
@@ -185,8 +185,8 @@ toQName n =
185185data Element = Element
186186 { name :: !QName
187187 , xtype :: !DatatypeRef
188− , minOccurs :: Int
189− , maxOccurs :: (Maybe Int)
188+ , minOccurs :: !Int
189+ , maxOccurs :: !Int
190190 , annotations :: [Annotation]
191191 } deriving (Show, Eq)
192192
src/Text/XSD/Parser.hs+4−2
@@ -82,8 +82,10 @@ toElem cursor = do
8282 name <- attrThrowXsd "name" el
8383 $ "Expected attribute 'name' for element: " <> show (node cursor)
8484 let
85− minOc = maybe 0 (read . T.unpack) (M.lookup "minOccurs" attrs)
86− maxOc = read . T.unpack <$> M.lookup "maxOccurs" attrs
85+ -- https://www.w3.org/TR/xmlschema-1/#cElement_Declarations
86+ -- https://www.w3.org/TR/xmlschema-1/#declare-element
87+ minOc = maybe 1 (read . T.unpack) (M.lookup "minOccurs" attrs)
88+ maxOc = maybe 1 (read . T.unpack) (M.lookup "maxOccurs" attrs)
8789 datatypeRef <- case mAttrType of
8890 Just dtn -> pure $ DatatypeRef dtn
8991 Nothing -> do