本文介绍了如何使用libxml2验证具有版本1.1中的模式的xml?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用libxml2用一个模式来验证xmls,并且因为一些
原因,我必须使用模式版本1.1,所以我开始我的模式头
像这样:

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">

我写了一个如下的compleType:

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>

它在version1.1中有效,但在version1.0中无效。当我使用我的程序来解析这个模式:

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);

我在_schema中有一个空指针。
但是如果我删除了上层complexType,一切都OK。所以我想可能是根本原因是libxml2只支持schema1.0在我的代码。所以有什么解决方案使libxml2与模式版本1.1?我必须使用其一些新的功能。
任何建议都会有帮助!谢谢!

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!

推荐答案

libxml2尚未更新以支持XSD 1.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.

这篇关于如何使用libxml2验证具有版本1.1中的模式的xml?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 23:08