Is xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” a special case in XML?

前端 未结 4 778
栀梦
栀梦 2020-12-31 11:26

When we use a namespace, we should also indicate where its associated XSD is located at, as can be seen in the following example:



        
4条回答
  •  天涯浪人
    2020-12-31 12:16

    If you look to content of: http://www.w3.org/2001/XMLSchema-instance you found that there is text:

    ...
    
      
       
        

    XML Schema instance namespace

    See the XML Schema Recommendation for an introduction

    ...

    Because xmlns="http://www.w3.org/1999/xhtml" you see above link as HTML document.

    According to http://www.w3.org/TR/xmlschema-1/#schema-loc (Schema Representation Constraint: Schema Document Location Strategy) schema-aware processors may implement any combination of the following strategies, in any order:

    • Attempt to resolve the namespace name to locate such a resource.

    So http://www.w3.org/2001/XMLSchema-instance point to itself (yea, recursion!!).

    See similar answer: Where is the XSD file for "http://www.w3.org/2001/XMLSchema-instance"?

    PS. Any specialized XML processor can treat http://www.w3.org/2001/XMLSchema-instance as known thing without actually download this definition (and most do that).

    PPS. Semantic of http://www.w3.org/2001/XMLSchema-instance defined by XML Schema standard http://www.w3.org/TR/xmlschema-1/

提交回复
热议问题