XML中的schemaLocation属性

来源:互联网 发布:制造业软件 编辑:程序博客网 时间:2024/06/06 07:36

在 XML 实例文档中有时会发现有 schemaLocation 属性。很多人对此非常疑惑,搞不清这个属性究竟是什么意思,究竟该如何使用。 schemaLocation 属性用来引用(schema)模式文档,解析器可以在需要的情况下使用这个文档对 XML 实例文档进行校验。它的值(URI)是成对出现的,第一个值表示命名空间,第二个值则表示描述该命名空间的模式文档的具体位置,两个值之间以空格分隔。当然,在必要情况下,可以为 schemaLocation 属性指派多个这样的值对。 <p:Person xmlns:p="http://contoso.com/People" xmlns:v="http://contoso.com /Vehicles" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation= "http://contoso.com/People http://contoso.com/schemas/people.xsd http://contoso.com/schemas/Vehicles http://contoso.com/schemas/vehicles.xsd http://contoso.com/schemas/People http://contoso.com/schemas/people.xsd"> <name>John</name> <age>28</age> <height>59</height> <v:Vehicle> <color>Red</color> [...]




http://www.blogjava.net/javafuns/archive/2009/08/29/293049.html

0 0