Last active
December 19, 2015 18:59
-
-
Save plq/6002667 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE dtd [ | |
| <!ENTITY file SYSTEM "some_file"> | |
| ]> | |
| <SomeObject xmlns="some_ns"> | |
| <d>2013-07-15T20:21:43.476838</d> | |
| <i>5</i> | |
| <s>&file;</s> | |
| </SomeObject> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Traceback (most recent call last): | |
| File "validation_internal_error.py", line 31, in <module> | |
| schema.validate(elt) | |
| File "lxml.etree.pyx", line 3252, in lxml.etree._Validator.validate (src/lxml/lxml.etree.c:143796) | |
| File "xmlschema.pxi", line 151, in lxml.etree.XMLSchema.__call__ (src/lxml/lxml.etree.c:152165) | |
| lxml.etree.XMLSchemaValidateError: Internal error in XML Schema validation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <xs:schema xmlns:wsa="http://schemas.xmlsoap.org/ws/2003/03/addressing" xmlns:tns="some_ns" xmlns:plink="http://schemas.xmlsoap.org/ws/2003/05/partner-link/" | |
| xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:soap12env="http://www.w3.org/2003/05/soap-envelope/" xmlns:senc="http://schemas.xmlsoap.org/soap/encoding/" | |
| xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" | |
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:senv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap12enc="http://www.w3.org/2003/05/soap-encoding/" | |
| targetNamespace="some_ns" elementFormDefault="qualified"> | |
| <xs:complexType name="SomeObject"> | |
| <xs:sequence> | |
| <xs:element name="d" type="xs:dateTime" minOccurs="0" nillable="true"/> | |
| <xs:element name="i" type="xs:integer" minOccurs="0" nillable="true"/> | |
| <xs:element name="s" type="xs:string" minOccurs="0" nillable="true"/> | |
| </xs:sequence> | |
| </xs:complexType> | |
| <xs:element name="SomeObject" type="tns:SomeObject"/> | |
| </xs:schema> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| inst.xml:5: namespace warning : xmlns: URI some_ns is not absolute | |
| <SomeObject xmlns="some_ns"> | |
| ^ | |
| <?xml version="1.0"?> | |
| <!DOCTYPE dtd [ | |
| <!ENTITY file SYSTEM "some_file"> | |
| ]> | |
| <SomeObject xmlns="some_ns"> | |
| <d>2013-07-15T20:21:43.476838</d> | |
| <i>5</i> | |
| <s>&file;</s> | |
| </SomeObject> | |
| inst.xml:8: element s: Schemas validity error : Internal error: xmlSchemaVDocWalk, there is at least one entity reference in the node-tree currently being validated. Processing of entities with this XML Schema processor is not supported (yet). Please substitute entities before validation.. | |
| inst.xml validation generated an internal error |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| some_file_contents |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| from lxml.etree import XMLParser, fromstring, XMLSchema | |
| schema_doc = open('schema.xsd').read() | |
| inst_doc = open('inst.xml').read() | |
| parser = XMLParser(resolve_entities=False) | |
| elt = fromstring(inst_doc, parser) | |
| schema = XMLSchema(fromstring(schema_doc)) | |
| schema.validate(elt) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| xmllint --schema schema.xsd inst.xml | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment