git.iko.soy/typeable/xsd-parser
on master help sign in
Element default type (#9)
fb680f3Yuras
src/Xsd/Parser.hs+7−6
@@ -85,10 +85,9 @@ parseElement :: Cursor -> P Xsd.Element
85parseElement c = handleNamespaces c $ do
85parseElement c = handleNamespaces c $ do
86 name <- theAttribute "name" c
86 name <- theAttribute "name" c
87
87
88− -- XXX: generalaze RefOr parsing
89 tp <- case anAttribute "type" c of
88 tp <- case anAttribute "type" c of
90 Just t -> Xsd.Ref <$> makeQName c t
89 Just t -> Xsd.Ref <$> makeQName c t
91− _ -> Xsd.Inline <$> parseType c
90+ _ -> maybe (Xsd.Ref anyType) Xsd.Inline <$> parseType c
92
91
93 minOccurs <- case anAttribute "minOccurs" c of
92 minOccurs <- case anAttribute "minOccurs" c of
94 Nothing -> return 1
93 Nothing -> return 1
@@ -120,16 +119,18 @@ parseElement c = handleNamespaces c $ do
120 , Xsd.elementOccurs = (minOccurs, maxOccurs)
119 , Xsd.elementOccurs = (minOccurs, maxOccurs)
121 , Xsd.elementNillable = nillable
120 , Xsd.elementNillable = nillable
122 }
121 }
122+ where
123+ anyType = Xsd.QName (Just (Xsd.Namespace Xsd.schemaNamespace)) "anyType"
123
124
124-- | Parse inline type, simple or complex
125-- | Parse inline type, simple or complex
125−parseType :: Cursor -> P Xsd.Type
126+parseType :: Cursor -> P (Maybe Xsd.Type)
126parseType c = do
127parseType c = do
127 simpleTypeAxis <- makeElemAxis "simpleType"
128 simpleTypeAxis <- makeElemAxis "simpleType"
128 complexTypeAxis <- makeElemAxis "complexType"
129 complexTypeAxis <- makeElemAxis "complexType"
129 case (c $/ simpleTypeAxis, c $/ complexTypeAxis) of
130 case (c $/ simpleTypeAxis, c $/ complexTypeAxis) of
130− ([], []) -> parseError c "No type"
131+ ([], []) -> return Nothing
131− ([t], []) -> Xsd.TypeSimple <$> parseSimpleType t
132+ ([t], []) -> Just . Xsd.TypeSimple <$> parseSimpleType t
132− ([], [t]) -> Xsd.TypeComplex <$> parseComplexType t
133+ ([], [t]) -> Just . Xsd.TypeComplex <$> parseComplexType t
133 _ -> parseError c "Multiple types"
134 _ -> parseError c "Multiple types"
134
135
135-- | Top level simple type
136-- | Top level simple type
xsts-test/Main.hs+1−1
@@ -54,7 +54,7 @@ dumpResults stats = IO.withFile "xsts.md" IO.WriteMode $ \h -> do
54 ]
54 ]
55
55
56expectedFailures :: Int
56expectedFailures :: Int
57−expectedFailures = 5316
57+expectedFailures = 5080
58
58
59main :: IO ()
59main :: IO ()
60main = do
60main = do
xsts.md+33−33
@@ -15,14 +15,14 @@ unsignedIntegers | 8 | 8
15UnitsLength | 8 | 7
15UnitsLength | 8 | 7
16union | 19 | 6
16union | 19 | 6
17CTA | 6 | 4
17CTA | 6 | 4
18−TypeAlternativeTests | 23 | 8
18+TypeAlternativeTests | 23 | 9
19time | 1 | 1
19time | 1 | 1
20TargetNS | 2 | 0
20TargetNS | 2 | 0
21substitutionGroup | 5 | 2
21substitutionGroup | 5 | 2
22rf-whiteSpace | 2 | 2
22rf-whiteSpace | 2 | 2
23RestrictionOfComplexTypes | 13 | 11
23RestrictionOfComplexTypes | 13 | 11
24RegularExpression | 8 | 8
24RegularExpression | 8 | 8
25−PopenContent | 24 | 15
25+PopenContent | 24 | 13
26list | 2 | 1
26list | 2 | 1
27IdentityConstraint | 12 | 7
27IdentityConstraint | 12 | 7
28ID_IDREF | 77 | 44
28ID_IDREF | 77 | 44
@@ -40,11 +40,11 @@ defaultAttributesApply | 17 | 14
40dayTimeDuration | 24 | 8
40dayTimeDuration | 24 | 8
41dateTimeStamp | 28 | 7
41dateTimeStamp | 28 | 7
42date | 1 | 1
42date | 1 | 1
43−CyclicDependencies_Redefine_Include_Import_Override | 5 | 1
43+CyclicDependencies_Redefine_Include_Import_Override | 5 | 0
44−constraintsOnAttribute | 16 | 12
44+constraintsOnAttribute | 16 | 10
45−ConditionalInclusion | 3 | 1
45+ConditionalInclusion | 3 | 2
46−assertion | 51 | 40
46+assertion | 51 | 42
47−Assert | 35 | 24
47+Assert | 35 | 25
48anyAttribute | 9 | 7
48anyAttribute | 9 | 7
49allGroup | 9 | 8
49allGroup | 9 | 8
50IRI | 1 | 0
50IRI | 1 | 0
@@ -57,44 +57,44 @@ VC | 24 | 9
57TargetNS | 4 | 0
57TargetNS | 4 | 0
58Subsgroup | 6 | 3
58Subsgroup | 6 | 3
59Simple | 58 | 31
59Simple | 58 | 31
60−Override | 30 | 20
60+Override | 30 | 21
61−Open | 51 | 25
61+Open | 51 | 34
62−Missing | 6 | 4
62+Missing | 6 | 5
63Id | 32 | 7
63Id | 32 | 7
64CTA | 44 | 13
64CTA | 44 | 13
65−Complex | 25 | 7
65+Complex | 25 | 11
66Assert | 34 | 2
66Assert | 34 | 2
67−All | 62 | 33
67+All | 62 | 29
68BoeingXSDTestCases | 6 | 0
68BoeingXSDTestCases | 6 | 0
69−MS-Wildcards2006-07-15 | 315 | 195
69+MS-Wildcards2006-07-15 | 315 | 210
70MS-SimpleType2006-07-15 | 333 | 146
70MS-SimpleType2006-07-15 | 333 | 146
71MS-Schema2006-07-15 | 124 | 56
71MS-Schema2006-07-15 | 124 | 56
72MS-Regex2006-07-15 | 2590 | 1988
72MS-Regex2006-07-15 | 2590 | 1988
73−MS-Particles2006-07-15 | 855 | 398
73+MS-Particles2006-07-15 | 855 | 491
74−MS-Notations2006-07-15 | 116 | 42
74+MS-Notations2006-07-15 | 116 | 40
75−MS-ModelGroups2006-07-15 | 391 | 190
75+MS-ModelGroups2006-07-15 | 391 | 221
76−MS-IdentityConstraint2006-07-15 | 844 | 229
76+MS-IdentityConstraint2006-07-15 | 844 | 231
77−MS-Group2006-07-15 | 218 | 73
77+MS-Group2006-07-15 | 218 | 69
78−MS-Errata102006-07-15 | 19 | 8
78+MS-Errata102006-07-15 | 19 | 10
79−MS-Element2006-07-15 | 355 | 138
79+MS-Element2006-07-15 | 355 | 150
80−MS-DataTypes2006-07-15 | 2247 | 1078
80+MS-DataTypes2006-07-15 | 2247 | 1084
81−MS-ComplexType2006-07-15 | 550 | 262
81+MS-ComplexType2006-07-15 | 550 | 270
82−MS-Attribute2006-07-15 | 279 | 138
82+MS-Attribute2006-07-15 | 279 | 137
83−MS-AttributeGroup2006-07-15 | 114 | 67
83+MS-AttributeGroup2006-07-15 | 114 | 64
84−MS-Annotations2006-07-15 | 80 | 51
84+MS-Annotations2006-07-15 | 80 | 50
85−MS-Additional2006-07-15 | 253 | 134
85+MS-Additional2006-07-15 | 253 | 157
86Wildcard | 26 | 22
86Wildcard | 26 | 22
87−Schema | 6 | 0
87+Schema | 6 | 6
88SType | 138 | 123
88SType | 138 | 123
89Notation | 13 | 8
89Notation | 13 | 8
90−MGroupDef | 19 | 10
90+MGroupDef | 19 | 8
91−MGroup | 40 | 30
91+MGroup | 40 | 24
92−IdConstrDefs | 27 | 21
92+IdConstrDefs | 27 | 19
93−ElemDecl | 227 | 86
93+ElemDecl | 227 | 133
94CType | 31 | 15
94CType | 31 | 15
95AttrUse | 4 | 1
95AttrUse | 4 | 1
96−AttrDecl | 83 | 71
96+AttrDecl | 83 | 73
97−AGroupDef | 13 | 7
97+AGroupDef | 13 | 6
98suntest | 52 | 19
98suntest | 52 | 19
99NIST2004-01-14 | 3953 | 3873
99NIST2004-01-14 | 3953 | 3873
100introspection | 1 | 0
100introspection | 1 | 0