Edmund
Edmund

Reputation: 757

How can I read multiple xsd strings into xmlschema

I have multiple XSD strings in my Python program, for example.

xsd1 = '''<?xml version...
   <xs:schema targetNamespace="...
'''
xsd2 = '''...'''

import xmlschema
schema = xmlschema.XMLSchema([xsd1, xsd2]) # it seems xmlschema does not accept such arguments
# then using schema to validate xml files

The two XSD have different target name spaces. How can I read them into xmlschema and validate xml files?

Upvotes: 1

Views: 1022

Answers (1)

kimbert
kimbert

Reputation: 2422

Ideally the xmlschema.XMLSchema() constructor would accept a list of file locations and assemble a single XSD model from them all (Eclipse EMF XSD model can do this). But it looks as if xmlschema does not do that trick.

The workaround is to create a single wrapper XSD that imports/includes the other XSDs, and then give the wrapper XSD to xmlschema.

Upvotes: 1

Related Questions