开发者

XML targetNamespace and unqualified declaration of elements

I'm somewhat confused as to how the targetNamespace attribute in an XML schema affects the naming of elements. I'm getting an error validating the following:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="test" version="1.0">
    <x开发者_运维技巧s:element name="testType" type="testType"/>
    <xs:complexType name="testType">
        <xs:sequence>
            <xs:element name="testSubtype" type="testSubType" />
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="testSubType">
        <!-- some fields -->
    </xs:complexType>
</xs:schema>

XMLSpy is stating it Cannot resolve the unqualified declaration or definition 'testSubType'. How can I resolve this? I need to keep the targetNamespace attribute in there. I've tried changing testSubType to test:testSubType in various areas but this doesn't seem to work.


Either add the xmlns="test" attribute to the schema element in order declare that default namespace for this schema is "test" or add xmlns:t="test" to declare that t is the prefix for the "test" namespace and use that prefix like type=t:testSubType when referencing types that you defined in this namespace (which you're doing by saying test is your targetNamespace).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜