XML Schema Header & Namespace Config

后端 未结 3 1355
执笔经年
执笔经年 2020-12-23 22:54

Migrating from DTD to XSD and for some reason the transition is a bumpy one. I understand how to define the schema once I\'m inside the root t

3条回答
  •  天命终不由人
    2020-12-23 23:21

    • xmlns="uri1" and xmlns:whatever="uri2" are namespace node and not attributes. Their role is to say that when you see element in your XML document named whatever:myElement, then the element belongs to the "whatever" namespace. This "whatever namespace" is identified by the uri declared in the namespace node.
    • targetNamespace is an attribute. It contains an URI that identify the elements, types and group you define in your schema.
    • xsi:schemaLocation is quite different. It's an attribute that allow XML parsers to find the schema attached to an XML instance. You don't need it in schema.
    • With xs:import you can import schemas from different namespace to use their elements and types in your own schema. When using xs:import, the imported schema and the importing schema must have different namespace. Use xs:include if it's the same namespace.

提交回复
热议问题