targetNamespace and xmlns without prefix, what is the difference?

后端 未结 6 1687
忘掉有多难
忘掉有多难 2020-11-30 17:46

In an xml schema document, if I have both the targetNamespace and the xmlns without a prefix.



        
6条回答
  •  [愿得一人]
    2020-11-30 18:25

    namespace means like scope

    targetNamespace is an attribute of schema element defines namespace i.e. package in XSD file. By convention we use URI/URLs, but we could use any string.

    xmlns is an attribute is used to refer elements and datatypes that come from xmlns attribute value for the current element scope.

    For Example:

    • xmlns:xsd="http://www.w3.org/2001/XMLSchema" is with prefix as xsd means namespace should be prefixed with xsd:
    • xmlns="http://www.w3.org/2001/XMLSchema" without prefix is default
    • xmlns:p="http://www.example.com/People" is with prefix as p means namespace should be prefixed with p:

    Where xmlns:xsd and xmlns:p are QNames and xmlns is local name.

    The following image helps to understand XSD using Java analogy as per my knowledge:

提交回复
热议问题