欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

淺談XML Schema中的elementFormDefault屬性

 更新時間:2017年02月10日 09:16:34   投稿:jingxian  
下面小編就為大家?guī)硪黄獪\談XML Schema中的elementFormDefault屬性。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

elementFormDefault屬性與命名空間相關(guān),其值可設(shè)置為qualified或unqualified

如果設(shè)置為qualified:

在XML文檔中使用局部元素時,必須使用限定短名作為前綴

sean.xsd:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
 xmlns:sean="http://sean.com"
 targetNamespace="http://sean.com"
 elementFormDefault="qualified">
 <xs:element name="book_list">
 <xs:complexType>
 <xs:sequence>
 <xs:element name="book" type="xs:string"/>
 </xs:sequence>
 </xs:complexType>
 </xs:element>
</xs:schema>

sean.xml:

<?xml version="1.0" encoding="UTF-8"?>
<sean:book_list xmlns:sean="http://sean.com" 
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 xsi:schemaLocation="http://sean.com sean.xsd">
 <sean:book>test</sean:book>
</sean:book_list>

如果設(shè)置為unqualified:

在XML文檔中使用局部元素時,可以省略限定短名

sean.xsd:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
 xmlns:sean="http://sean.com"
 targetNamespace="http://sean.com"
 elementFormDefault="unqualified">
 <xs:element name="book_list">
 <xs:complexType>
 <xs:sequence>
 <xs:element name="book" type="xs:string"/>
 </xs:sequence>
 </xs:complexType>
 </xs:element>
</xs:schema>

sean.xml:

<?xml version="1.0" encoding="UTF-8"?>
<sean:book_list xmlns:sean="http://sean.com" 
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 xsi:schemaLocation="http://sean.com sean.xsd">
 <book>test</book>
</sean:book_list>

雖然會間接很多,但是由于去掉了命名空間,所以不是很好理解

類似的屬性還有attributeFormDefault,其規(guī)則與elementFormDefault是一樣的

以上這篇淺談XML Schema中的elementFormDefault屬性就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論