File tree Expand file tree Collapse file tree 3 files changed +56
-1
lines changed
main/java/org/xmlet/xsdparser/xsdelements Expand file tree Collapse file tree 3 files changed +56
-1
lines changed Original file line number Diff line number Diff line change @@ -195,7 +195,7 @@ public void setSimpleType(ReferenceBase simpleType) {
195
195
}
196
196
197
197
public XsdSimpleType getXsdSimpleType (){
198
- return simpleType instanceof ConcreteElement ? (XsdSimpleType ) simpleType .getElement () : null ;
198
+ return ( simpleType != null && simpleType . getElement () instanceof XsdSimpleType ) ? (XsdSimpleType ) simpleType .getElement () : null ;
199
199
}
200
200
201
201
public String getType () {
Original file line number Diff line number Diff line change
1
+ package org .xmlet .xsdparser ;
2
+
3
+ import org .junit .Test ;
4
+ import org .xmlet .xsdparser .core .XsdParser ;
5
+ import org .xmlet .xsdparser .xsdelements .XsdComplexType ;
6
+ import org .xmlet .xsdparser .xsdelements .XsdElement ;
7
+
8
+ import java .util .List ;
9
+ import java .util .logging .Level ;
10
+ import java .util .logging .Logger ;
11
+ import java .util .stream .Collectors ;
12
+
13
+ /*
14
+ * Sample code to test issue https://github.com/xmlet/XsdParser/issues/63
15
+ */
16
+ public class Issue63Test {
17
+
18
+ @ Test
19
+ public void testIssue63 () {
20
+ XsdParser xsdParser = new XsdParser ( "./src/test/resources/issue_63/a.xsd" );
21
+ List <XsdElement > elements = xsdParser .getResultXsdElements ().collect (Collectors .toList ());
22
+ for (XsdElement currentElement : elements ) {
23
+ XsdComplexType complexType = currentElement .getXsdComplexType ();
24
+ if ( complexType != null ) {
25
+ Logger .getAnonymousLogger ().log (Level .INFO , "current type : " +complexType );
26
+ // exception raised here
27
+ complexType .getXsdAttributes ().forEach ( a -> a .getAllRestrictions () );
28
+ }
29
+ }
30
+ }
31
+
32
+ }
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" ISO-8859-1" ?>
2
+ <!--
3
+ Sample test xsd for issue : https://github.com/xmlet/XsdParser/issues/63
4
+ java.lang.ClassCastException on XsdAttribute:198 - xsd parser version 1.2.9
5
+ -->
6
+ <xsd : schema xmlns =' http://www.w3.org/2000/10/XMLSchema'
7
+ targetNamespace=' https://github.com/xmlet/XsdParser/issues/63'
8
+ xmlns:doc=' https://github.com/xmlet/XsdParser/issues/63' xmlns : xsd =" http://www.w3.org/2001/XMLSchema" >
9
+
10
+ <xsd : element name =' info' >
11
+ <xsd : annotation >
12
+ <xsd : documentation >Some documentation text</xsd : documentation >
13
+ </xsd : annotation >
14
+ <xsd : complexType mixed =' true' >
15
+ <xsd : attribute name =' name' type =' xsd:string' use =' required' >
16
+ <xsd : annotation >
17
+ <xsd : documentation >More documentation text</xsd : documentation >
18
+ </xsd : annotation >
19
+ </xsd : attribute >
20
+ </xsd : complexType >
21
+ </xsd : element >
22
+
23
+ </xsd : schema >
You can’t perform that action at this time.
0 commit comments