Commit e99c7f51 authored by eRolland's avatar eRolland Committed by GitHub

Merge pull request #128 from pascal-schetelat/xsd_validation

Xsd validation
parents 8fd9ebc7 6dda9c5b
language: python
python:
- "2.7"
# command to install dependencies
install: "pip install -r requirements.txt"
# command to run tests
script:
- cd tests
- python -m pytest test_xsd_validation.py
lxml
pytest
\ No newline at end of file
from lxml import isoschematron
from lxml import etree
import os
from glob import glob
import pytest
schematron_path = os.path.join('..','schematron','energy.xsd')
sample_directory = os.path.join('..','samples')
citygml_files = glob(sample_directory+os.path.sep+'*.gml')
# need an internet connection to resolve the imported schemas
@pytest.mark.parametrize("file_path,expected", [(i, None) for i in citygml_files])
def test_simple_validation(file_path, expected):
with open(schematron_path) as f :
schematron_doc = etree.parse(f)
schematron = isoschematron.Schematron(schematron_doc)
with open(file_path) as gml_f:
gml_obj = etree.parse(gml_f)
assert schematron.validate(gml_obj)
from lxml import etree
import os
from glob import glob
import pytest
xsd_path = os.path.join('..','xsd','energy.xsd')
sample_directory = os.path.join('..','samples')
citygml_files = glob(sample_directory+os.path.sep+'*.gml')
with open(xsd_path) as f :
xmlschema_doc = etree.parse(f)
xmlschema = etree.XMLSchema(xmlschema_doc)
#XMLSchemaParseError -> need an internet connection to resolve the imported schemas
@pytest.mark.parametrize("file_path,expected", [(i, os.path.basename(i)) for i in citygml_files])
def test_simple_validation(file_path, expected):
print "-------"
print file_path
with open(file_path) as gml_f:
gml_obj = etree.parse(gml_f)
if not xmlschema.validate(gml_obj):
print "KO"
print xmlschema.error_log
assert False
else:
print 'OK'
assert True
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment