XSD架构错误:XmlSchema错误:元素http://www.w3.org/2001/XMLSchema:element在此上下文中无效

问题描述 投票:0回答:1

我正在尝试验证此XML文件第127行XmlSchema错误:元素http://www.w3.org/2001/XMLSchema:element在此上下文中无效。第125行,位置4。相关架构项目SourceUri:virtual://server/schema.xsd,第177行,位置2。

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:msg="urn:smco.messages" xmlns:md="urn:smco.marketData" xsi:schemaLocation="urn:smco.messages schema/smco_marketData-messages.xsd"
elementFormDefault="qualified">
    <xs:element name="msg:messageStandard">
        <xs:complexType>
            <xs:sequence>

                <xs:element name="msg:messageId" type="xs:token"/>
                <xs:element name="msg:timeStamp" type="xs:dateTime"/>
                <xs:element ref="msg:messagePublisher" type="xs:token"/>
                <xs:element name="msg:singleObjectMessage" maxOccurs="unbounded" />
                <xs:element name="msg:messageObjectCount" type="xs:decimal"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>


    <xs:simpleType name="type-dates_openEnded">
        <xs:annotation>
            <xs:documentation xml:lang="EN">XML date type with the token 'open' where 'open' is later/before (greater/lesser) than any date value</xs:documentation>
        </xs:annotation>
        <xs:union memberTypes="xs:date">
            <xs:simpleType>
                <xs:restriction base="xs:token">
                    <xs:enumeration value="open"/>
                </xs:restriction>
            </xs:simpleType>
        </xs:union>
    </xs:simpleType>

    <xs:complexType name="type-scheme">
        <xs:annotation>
            <xs:documentation xml:lang="en">The base class for all types which define coding schemes. An instance uses the </xs:documentation>
            <xs:documentation xml:lang="en">An instance uses the attributes to fully specify the value domaine by stating it's identification and linking to the documentation of its scope and description of each of its possible values.</xs:documentation>
        </xs:annotation>
        <xs:simpleContent>
            <xs:extension base="xs:normalizedString">
                <xs:attribute name="schemeValues" type="xs:anyURI"/>
                <xs:attribute name="schemeCode" type="xs:normalizedString"/>
                <xs:attribute name="schemeName" type="xs:normalizedString"/>
                <xs:attribute name="schemeVersion" type="xs:normalizedString"/>
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>

    <xs:simpleType name="type-iso.country">
        <xs:annotation>
            <xs:documentation xml:lang="EN">Must conform to ISO 3166 - Representation of Countries</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:normalizedString">
            <xs:pattern value="[A-Z][A-Z]"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="type-iso.currency">
        <xs:annotation>
            <xs:documentation xml:lang="EN">Must conform to ISO 4217 - Representation of Currency and Funds</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:normalizedString">
            <xs:pattern value="[A-Z][A-Z][A-Z]"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="type-iso.market">
        <xs:annotation>
            <xs:documentation xml:lang="EN">Must conform to ISO 10383 - Representation of Market Identification Codes</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:pattern value="[A-Z][A-Z][A-Z][A-Z]" />
        </xs:restriction>
    </xs:simpleType>

    <xs:complexType name="type-msg.identificationCode">

        <xs:sequence>
            <xs:element name="msg:codeLevel" type="type-msg.identificationLevel"/>
            <xs:element name="msg:startDate" type="type-dates_openEnded">

            </xs:element>
            <xs:element name="msg:endDate" type="type-dates_openEnded">

            </xs:element>
            <xs:element name="msg:codeType" type="type-scheme">

            </xs:element>
            <xs:element name="msg:code" type="xs:string">

            </xs:element>

        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="type-inst.identificationCode">
        <xs:sequence>
            <xs:element name="inst:codeLevel" type="type-identificationLevel"/>
            <xs:element name="inst:startDate" type="type-dates_openEnded">
            </xs:element>
            <xs:element name="inst:endDate" type="type-dates_openEnded">
            </xs:element>
            <xs:element name="inst:codeType" type="type-scheme">

            </xs:element>
            <xs:element name="inst:code" type="xs:string">
            </xs:element>

        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="type-localizedString">
        <xs:simpleContent>
            <xs:extension base="xs:string">
                <xs:attribute name="language" type="xs:language"/>
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>

    <xs:complexType name="type-msg.identificationLevel">
        <xs:simpleContent>
            <xs:extension base="xs:string">
                <xs:attribute name="level" type="xs:string"/>
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>

    <xs:complexType name="type-msg:scope">
        <xs:simpleContent>
            <xs:element name="msg:market" type="type-scheme"/>
            <xs:element name="msg:actionType" type="xs:token"/>
        </xs:simpleContent>
        <xs:attribute name="intent" type="xs:string"/>
        <xs:attribute name="level" type="xs:string"/>
    </xs:complexType>


    <xs:complexType name="type-messagePurpose">
        <xs:sequence>
            <xs:element name="msg:effectiveDate" type="xs:date"/>
            <xs:element name="msg:intendedScopes">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="msg:scope" type="type-msg:scope"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>


    <xs:element name="msg:singleObjectMessage" >
        <xs:complexType>
            <xs:sequence>
                <xs:element name="msg:messagePurpose" type="type-messagePurpose"/>
                <xs:element name="msg:content" type="content-marketQuotes"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <xs:complexType name="type-dataPoint">
        <xs:sequence> 
            <xs:element name="value1" type="type-typedValue" maxOccurs="unbounded"/>
            <xs:element name="value2" type="type-typedValue" maxOccurs="unbounded"/>
            <xs:element name="value3" type="type-typedValue" maxOccurs="unbounded"/>
            <xs:element name="value4" type="type-typedValue" maxOccurs="unbounded"/>
            <xs:element name="value5" type="type-typedValue" maxOccurs="unbounded"/>
            <xs:element name="value6" type="type-typedValue" maxOccurs="unbounded"/>
            <xs:element name="value7" type="type-typedValue" maxOccurs="unbounded"/>
            <xs:element name="value8" type="type-typedValue" maxOccurs="unbounded"/>
        </xs:sequence> 
        <xs:attribute  name="structureType" type="xs:string"/>
    </xs:complexType>

    <xs:complexType name="type-typedValue">
        <xs:simpleContent>
            <xs:extension base="xs:decimal">
                <xs:attribute name="dataType" type="xs:string" use="required"/> 
                <xs:attribute name="dataUnit" type="xs:string" use="required"/> 
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>

    <xs:complexType name="content-marketQuotes">
        <xs:sequence>
            <xs:element name="msg:standardIdentifier" type="type-msg.identificationCode"/>
            <xs:element name="msg:knownIdentifiers" >
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="msg:identifier" type="type-msg.identificationCode" maxOccurs="unbounded"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element name="msg:extendedCFICode" type="type-scheme"/>
            <xs:element name="msg:observation" maxOccurs="unbounded">
                <xs:complexType>
                    <xs:sequence> 
                        <xs:element name="md:source" type="xs:string"/>
                        <xs:element name="md:market" type="type-scheme"/>
                        <xs:element name="md:country" type="type-scheme"/>
                        <xs:element name="md:currency" type="type-scheme"/>
                        <xs:element name="md:pointLabel" type="xs:string"/>
                        <xs:element name="md:date" type="xs:date"/>
                        <xs:element name="md:endDate" type="type-dates_openEnded"/>
                        <xs:element name="md:dataPoint" type="type-dataPoint"/>
                    </xs:sequence>
                    <xs:attribute name="quoteType" type="xs:string" use="required"/>
                </xs:complexType>
            </xs:element>
            <xs:element name="msg:observationCount" type="xs:decimal"/>
        </xs:sequence>
        <xs:attribute name="xsi:type" type="xs:string" use="required"/>
    </xs:complexType>

</xs:schema>

在此行-> xs:element name =“ msg:market” type =“ type-scheme”我收到错误!谁能帮忙?

xml xsd xml-parsing xsd-validation
1个回答
0
投票

我看到了另一个错误:我的模式处理器告诉我name="msg:messageId"无效。您在整个过程中都使用了此构造,所以我看到很多错误,这可能掩盖了处理器给您的错误。

XSD中的name属性始终是不合格的本地名称;当您声明组件时,它们隐式地放在模式文档的targetNamespace中,或者(如果没有form="unqualified",则在无名称空间中)。

© www.soinside.com 2019 - 2024. All rights reserved.