How to use libxml2 validate a xml with a schema in version 1.1?

十年热恋 提交于 2019-12-10 20:47:15

问题


I use libxml2 to validate xmls with a schema, and because of some reasons I must use schema version 1.1, so I began my schema header like this:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" elementFormDefault="qualified" attributeFormDefault="unqualified" vc:minVersion="1.1">

and I wrote a compleType like this:

<xs:complexType name="test-type">
    <xs:all>
        <xs:element name="test"></xs:element>
        <xs:element name="test1" minOccurs="0" maxOccurs="4"></xs:element>
    </xs:all>
</xs:complexType>

It's valid in version1.1, but invalid in version1.0. When I used my program to parse this schema:

xmlSchemaParseCtxtPtr ctxt;
xmlLineNumberDefault(1);
ctxt=xmlSchemaNewParserCtxt("schema.xsd");
_xmlSchema* _schema = xmlSchemaParse(ctxt);

I got a null-pointer in _schema. But if i removed that upper complexType, everything was OK. So I thought may be the root cause was libxml2 only supported schema version1.0 "in my code". So is there any solution to make libxml2 work with schema version1.1? I must use some of its new features. Any suggestion will help! Thanks!


回答1:


libxml2 has not been updated to support XSD 1.1. As far as I am aware there is no active development on the product so this is unlikely to happen. You will need to find a different schema processor.



来源:https://stackoverflow.com/questions/26668140/how-to-use-libxml2-validate-a-xml-with-a-schema-in-version-1-1

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!