File tree 3 files changed +40
-3
lines changed
3 files changed +40
-3
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { ValidationResult } from "@lib/types/validation";
2
2
import { Validator , ValidatorImpl } from "@lib/validator/validator" ;
3
3
import { XMLParser , XMLParserImpl } from "@lib/xml/parser" ;
4
4
import { XSDParser } from "@lib/xsd/parser" ;
5
- import { XSDStandardParserImpl } from "@lib/xsd/standard " ;
5
+ import { XSDPipelineParserImpl } from "@lib/xsd/pipeline/parser " ;
6
6
7
7
export class Checkr {
8
8
@@ -12,7 +12,7 @@ export class Checkr {
12
12
13
13
constructor ( ) {
14
14
this . xmlParser = new XMLParserImpl ( ) ;
15
- this . xsdParser = new XSDStandardParserImpl ( this . xmlParser ) ;
15
+ this . xsdParser = new XSDPipelineParserImpl ( this . xmlParser ) ;
16
16
this . validator = new ValidatorImpl ( this . xmlParser , this . xsdParser ) ;
17
17
}
18
18
Original file line number Diff line number Diff line change @@ -402,6 +402,43 @@ const runCommonTests = (xsdParser: XSDParser) => {
402
402
} ) ;
403
403
} ) ;
404
404
405
+ it ( 'should parse books xsd' , async ( ) => {
406
+ const xsd = `
407
+ <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
408
+ targetNamespace="urn:books"
409
+ xmlns:bks="urn:books">
410
+
411
+ <xsd:element name="books" type="bks:BooksForm"/>
412
+
413
+ <xsd:complexType name="BooksForm">
414
+ <xsd:sequence>
415
+ <xsd:element name="book"
416
+ type="bks:BookForm"
417
+ minOccurs="0"
418
+ maxOccurs="unbounded"/>
419
+ </xsd:sequence>
420
+ </xsd:complexType>
421
+
422
+ <xsd:complexType name="BookForm">
423
+ <xsd:sequence>
424
+ <xsd:element name="author" type="xsd:string"/>
425
+ <xsd:element name="title" type="xsd:string"/>
426
+ <xsd:element name="genre" type="xsd:string"/>
427
+ <xsd:element name="price" type="xsd:float" />
428
+ <xsd:element name="pub_date" type="xsd:date" />
429
+ <xsd:element name="review" type="xsd:string"/>
430
+ </xsd:sequence>
431
+ <xsd:attribute name="id" type="xsd:string"/>
432
+ </xsd:complexType>
433
+ </xsd:schema>
434
+ ` ;
435
+
436
+ await parseAndExpect ( xsd , ( schema ) => {
437
+ expect ( schema . elements ) . toHaveLength ( 0 ) ;
438
+ } ) ;
439
+
440
+ } ) ;
441
+
405
442
} ;
406
443
407
444
describe ( 'XSDParser Implementations' , ( ) => {
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ export class XSDStandardParserImpl implements XSDParser {
9
9
const doc = this . xmlParser . parse ( xsd ) ;
10
10
11
11
// Ensure documentElement is valid
12
- if ( ! doc . documentElement || doc . documentElement . tagName !== "xs:schema" ) {
12
+ if ( ! doc . documentElement || doc . documentElement . tagName . indexOf ( 'schema' ) === - 1 ) {
13
13
throw new Error ( "Invalid XSD: Missing root <xs:schema>" ) ;
14
14
}
15
15
You can’t perform that action at this time.
0 commit comments