1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Is it possible to validate an XML file against XSD 1.1 in Python?

Discussão em 'Python' iniciado por Stack, Setembro 10, 2024.

  1. Stack

    Stack Membro Participativo

    I want validate an XML file against an XSD file using lxml.XMLSchema. But the problem is the XSD is in 1.1. So it doesn't work.

    This is a part of the XML:

    <?xml version="1.0" encoding="UTF-8"?>
    <dictionary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="!!assert.xsd">
    <SizeType>10</SizeType>
    </dictionary>


    And this is its XSD file:

    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    elementFormDefault="qualified">
    <xs:element name="SizeType">
    <xs:simpleType>
    <xs:restriction base="xs:integer">
    <xs:assertion test="$value = 10"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    </xs:schema>


    So, is it possible to validate an XML file against a XSD file that uses xs:assertion statements (1.1)?

    I think this question is closely related to this: lxml with schema 1.1

    Continue reading...

Compartilhe esta Página