git.iko.soy/typeable/xsd-parser
on master help sign in
Element default type (#9)

If element doesn't have type specified, then it's xs:anyType

commitfb680f35cd8a13442cc6bf9125b3ae34dfb5245f authorYuras <shumovichy@gmail.com> dateThu 13 Feb 2020, 16:58 (7 years ago) parent7e79343
3 files changed+41−40
src/Xsd/Parser.hs+7−6 xsts-test/Main.hs+1−1 xsts.md+33−33
src/Xsd/Parser.hs+7−6
@@ -85,10 +85,9 @@ parseElement :: Cursor -> P Xsd.Element
8585parseElement c = handleNamespaces c $ do
8686 name <- theAttribute "name" c
8787
88− -- XXX: generalaze RefOr parsing
8988 tp <- case anAttribute "type" c of
9089 Just t -> Xsd.Ref <$> makeQName c t
91− _ -> Xsd.Inline <$> parseType c
90+ _ -> maybe (Xsd.Ref anyType) Xsd.Inline <$> parseType c
9291
9392 minOccurs <- case anAttribute "minOccurs" c of
9493 Nothing -> return 1
@@ -120,16 +119,18 @@ parseElement c = handleNamespaces c $ do
120119 , Xsd.elementOccurs = (minOccurs, maxOccurs)
121120 , Xsd.elementNillable = nillable
122121 }
122+ where
123+ anyType = Xsd.QName (Just (Xsd.Namespace Xsd.schemaNamespace)) "anyType"
123124
124125-- | Parse inline type, simple or complex
125−parseType :: Cursor -> P Xsd.Type
126+parseType :: Cursor -> P (Maybe Xsd.Type)
126127parseType c = do
127128 simpleTypeAxis <- makeElemAxis "simpleType"
128129 complexTypeAxis <- makeElemAxis "complexType"
129130 case (c $/ simpleTypeAxis, c $/ complexTypeAxis) of
130− ([], []) -> parseError c "No type"
131− ([t], []) -> Xsd.TypeSimple <$> parseSimpleType t
132− ([], [t]) -> Xsd.TypeComplex <$> parseComplexType t
131+ ([], []) -> return Nothing
132+ ([t], []) -> Just . Xsd.TypeSimple <$> parseSimpleType t
133+ ([], [t]) -> Just . Xsd.TypeComplex <$> parseComplexType t
133134 _ -> parseError c "Multiple types"
134135
135136-- | Top level simple type
xsts-test/Main.hs+1−1
@@ -54,7 +54,7 @@ dumpResults stats = IO.withFile "xsts.md" IO.WriteMode $ \h -> do
5454 ]
5555
5656expectedFailures :: Int
57−expectedFailures = 5316
57+expectedFailures = 5080
5858
5959main :: IO ()
6060main = do
xsts.md+33−33
@@ -15,14 +15,14 @@ unsignedIntegers | 8 | 8
1515UnitsLength | 8 | 7
1616union | 19 | 6
1717CTA | 6 | 4
18−TypeAlternativeTests | 23 | 8
18+TypeAlternativeTests | 23 | 9
1919time | 1 | 1
2020TargetNS | 2 | 0
2121substitutionGroup | 5 | 2
2222rf-whiteSpace | 2 | 2
2323RestrictionOfComplexTypes | 13 | 11
2424RegularExpression | 8 | 8
25−PopenContent | 24 | 15
25+PopenContent | 24 | 13
2626list | 2 | 1
2727IdentityConstraint | 12 | 7
2828ID_IDREF | 77 | 44
@@ -40,11 +40,11 @@ defaultAttributesApply | 17 | 14
4040dayTimeDuration | 24 | 8
4141dateTimeStamp | 28 | 7
4242date | 1 | 1
43−CyclicDependencies_Redefine_Include_Import_Override | 5 | 1
44−constraintsOnAttribute | 16 | 12
45−ConditionalInclusion | 3 | 1
46−assertion | 51 | 40
47−Assert | 35 | 24
43+CyclicDependencies_Redefine_Include_Import_Override | 5 | 0
44+constraintsOnAttribute | 16 | 10
45+ConditionalInclusion | 3 | 2
46+assertion | 51 | 42
47+Assert | 35 | 25
4848anyAttribute | 9 | 7
4949allGroup | 9 | 8
5050IRI | 1 | 0
@@ -57,44 +57,44 @@ VC | 24 | 9
5757TargetNS | 4 | 0
5858Subsgroup | 6 | 3
5959Simple | 58 | 31
60−Override | 30 | 20
61−Open | 51 | 25
62−Missing | 6 | 4
60+Override | 30 | 21
61+Open | 51 | 34
62+Missing | 6 | 5
6363Id | 32 | 7
6464CTA | 44 | 13
65−Complex | 25 | 7
65+Complex | 25 | 11
6666Assert | 34 | 2
67−All | 62 | 33
67+All | 62 | 29
6868BoeingXSDTestCases | 6 | 0
69−MS-Wildcards2006-07-15 | 315 | 195
69+MS-Wildcards2006-07-15 | 315 | 210
7070MS-SimpleType2006-07-15 | 333 | 146
7171MS-Schema2006-07-15 | 124 | 56
7272MS-Regex2006-07-15 | 2590 | 1988
73−MS-Particles2006-07-15 | 855 | 398
74−MS-Notations2006-07-15 | 116 | 42
75−MS-ModelGroups2006-07-15 | 391 | 190
76−MS-IdentityConstraint2006-07-15 | 844 | 229
77−MS-Group2006-07-15 | 218 | 73
78−MS-Errata102006-07-15 | 19 | 8
79−MS-Element2006-07-15 | 355 | 138
80−MS-DataTypes2006-07-15 | 2247 | 1078
81−MS-ComplexType2006-07-15 | 550 | 262
82−MS-Attribute2006-07-15 | 279 | 138
83−MS-AttributeGroup2006-07-15 | 114 | 67
84−MS-Annotations2006-07-15 | 80 | 51
85−MS-Additional2006-07-15 | 253 | 134
73+MS-Particles2006-07-15 | 855 | 491
74+MS-Notations2006-07-15 | 116 | 40
75+MS-ModelGroups2006-07-15 | 391 | 221
76+MS-IdentityConstraint2006-07-15 | 844 | 231
77+MS-Group2006-07-15 | 218 | 69
78+MS-Errata102006-07-15 | 19 | 10
79+MS-Element2006-07-15 | 355 | 150
80+MS-DataTypes2006-07-15 | 2247 | 1084
81+MS-ComplexType2006-07-15 | 550 | 270
82+MS-Attribute2006-07-15 | 279 | 137
83+MS-AttributeGroup2006-07-15 | 114 | 64
84+MS-Annotations2006-07-15 | 80 | 50
85+MS-Additional2006-07-15 | 253 | 157
8686Wildcard | 26 | 22
87−Schema | 6 | 0
87+Schema | 6 | 6
8888SType | 138 | 123
8989Notation | 13 | 8
90−MGroupDef | 19 | 10
91−MGroup | 40 | 30
92−IdConstrDefs | 27 | 21
93−ElemDecl | 227 | 86
90+MGroupDef | 19 | 8
91+MGroup | 40 | 24
92+IdConstrDefs | 27 | 19
93+ElemDecl | 227 | 133
9494CType | 31 | 15
9595AttrUse | 4 | 1
96−AttrDecl | 83 | 71
97−AGroupDef | 13 | 7
96+AttrDecl | 83 | 73
97+AGroupDef | 13 | 6
9898suntest | 52 | 19
9999NIST2004-01-14 | 3953 | 3873
100100introspection | 1 | 0