0

私は XML 初心者で、スキーマの解析に関して奇妙な問題を抱えています。実行できる最小限の例を次に示します。

#! /usr/bin/env python
from lxml import etree
from StringIO import StringIO

XML = StringIO('''<?xml version="1.0" encoding="ISO-8859-1" ?>
<xs:schema xmlns="http://www.w3.org/2001/XMLSchema"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
    <xs:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
    <xs:complexType name="ArrayOfDocumentLink">
        <xs:complexContent>
            <xs:restriction base="soapenc:Array">
                <xs:attribute ref="soapenc:arrayType" wsdl:arrayType="tns:DocumentLink[]"/>
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>
</xs:schema>''')

etree.XMLSchema(file=XML)

与える

lxml.etree.XMLSchemaParseError: complex type 'ArrayOfDocumentLink', attribute 'base': The QName value '{http://schemas.xmlsoap.org/soap/encoding/}Array' does not resolve to a(n) simple type definition., line 7

私は無知です。さまざまなメーリング リストとこのSO の質問は、すべての定義を外部ファイルに収集することを含む回避策があることを示唆しています。しかし、それは初心者が何が起こっているのかを理解するのに本当に役立ちません. どんな洞察も大歓迎です!

4

1 に答える 1

2

名前空間http://schemas.xmlsoap.org/soap/encoding/のスキーマ定義をインポートする必要があることを示しましたが、これらの定義の場所をプロセッサに伝えていません。この名前空間のスキーマ ドキュメントの場所をプロセッサに伝える schemaLocation 属性を (xs:import に) 追加してみてください。

于 2012-08-29T07:49:17.140 に答える