【问题标题】:The QName value '{http://schemas.xmlsoap.org/soap/encoding/}Array' does not resolve to a(n) simple type definitionQName 值“{http://schemas.xmlsoap.org/soap/encoding/}Array”不解析为(n)简单类型定义
【发布时间】:2012-08-23 13:36:36
【问题描述】:

我是一名 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

我一无所知。各种邮件列表和this SO 问题表明存在一种解决方法,将所有定义收集到外部文件中。但这并不能真正帮助新手了解正在发生的事情。非常感谢任何见解!

【问题讨论】:

    标签: xml soap wsdl xsd lxml


    【解决方案1】:

    您已经指出需要为命名空间http://schemas.xmlsoap.org/soap/encoding/ 导入架构定义,但您没有告诉处理器在哪里可以找到这些定义。尝试添加(到 xs:import)一个 schemaLocation 属性,该属性告诉处理器在哪里可以找到此命名空间的架构文档。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-07-22
    • 1970-01-01
    • 1970-01-01
    • 2014-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多