How do XML namespaces work without a working network connection?

后端 未结 4 1357
南笙
南笙 2020-12-05 14:28




        
4条回答
  •  南笙
    南笙 (楼主)
    2020-12-05 15:11

    An XML namespace is a component of an element's name, which you can bind to a prefix when you write xmlns:="". That helps to avoid naming conflicts between different XML schemas, so that you can mix elements from two schemas that happen to have the same name. For example, you might have two schemas that both have link elements with different meanings, and the namespace prefix lets you distinguish between them by writing either foo:link or bar:link. Namespaces are typically in the form of a URL, but the parser just treats it as a string, it doesn't try to fetch anything from that URL.

    You're correct about the second part, the XSI:SchemaLocation element. See this answer for why it's still able to validate the schema without a network connection.

提交回复
热议问题