Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions __tests__/XMLSchemata.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const path = require('path')
const { XMLSchemata } = require('../')

test('cyclic import', async () => {
const xsdPath = path.join(__dirname, '..', '__data__', '30213','RequestEGRN_v026.xsd')

const schemata = await new Promise((resolve, reject) => {
XMLSchemata.fromFile(xsdPath)
.then(s => resolve(s))
.catch(e => reject(e))
})

expect(schemata).toBeDefined()
expect(schemata.size).toBeGreaterThan(0)
})
6 changes: 6 additions & 0 deletions lib/XMLSchemata.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const XMLSchemata = class extends Map {
new XMLSchemaXml (this)
new XMLSchemaBuiltIn (this)

this.loadedFiles = new Set()

this.addFile (fn)

}
Expand Down Expand Up @@ -159,6 +161,10 @@ const XMLSchemata = class extends Map {

addFile (fn, options = {}) {

if (this.loadedFiles.has (fn)) return

this.loadedFiles.add (fn)

options.dirname = path.dirname (fn)

const document = this.parser.process (fs.readFileSync (fn, 'utf-8'))
Expand Down