XML Schema nillable=¡±true¡± vs minOccurs=¡±0¡å
³ö´¦£ºhttp://www.dimuthu.org/blog/2008/08/18/xml-schema-nillabletrue-vs-minoccurs0/
¡¾Ç°ÑÔ¡¿Ò»¸öÔÂǰÑо¿¹ýnillable="true"ºÍ vs minOccurs="0"µÄÇø·Ö£¬Ã»ÓÐÏëµ½°¡£¬½ñÌì¾Í¼Ç²»µÃÁË£¬¿´À´ÕæÊǺüÇÐÔ²»ÈçÀñÊÍ·°¡£¬¿öÇÒÎÒ»¹Ã´µÄºÃ¼ÇÐÔ¡£¡£¡£¡£
¡¾×ܽ᡿ӢÎÄÒ»ÑÛ¿´²»³ö½áÂÛ£¬ËµµãººÓïÖ±½ÓЩ£¬±ð˵ÎÒÍÁ¹þ~
nillable="true"£º¸ÃÔªËØµÄÖµ¿ÉÒÔΪ¿Õ£¬µ«ÊǸÃÔªËØ²»ÄÜÊ¡ÂÔ£¬Ò²¾ÍÊÇ˵£¬Ö»ÄÜ£º
<minzero xsi:nil="true"><minzero>
¶ø²»ÄÜÖ±½Ó½«minzeroÕâ¸öÔªËØÈ¥µô
£¨×¢Ò⣺xsi:nil="true"»òÕßxsi:nil="1"Ó¦¸Ã¾ÍÊDZíʾÕâ¸öÔªËØÎª¿Õ£©
minOccurs="0"£º¸ÃÔªËØ¿ÉÒÔÖ±½Ó±»Ê¡ÂÔµô£¬µ«ÊDz»ÄÜÈøÃÔªËØµÄֵΪ¿Õ£¬Ò²¾ÍÊÇ˵£¬²»ÄÜ£º
<minzero xsi:nil="true"><minzero>
In a WSDL, XML Schema is the section where it define the message format for each operations, which eventually become the real API that users are interested. And it is the most tricky part of the WSDL. Nowadays there are many tools that you can design and use WSDLs without any needs in knowing the meaning of a single line of the WSDL. But there are situations that you may find it is better you have some knowledge in XML Schema section and in WSDL overall.
For this post I m taking a simple example of use of nillable=”true” and minOccurs=”0″. Take the following example.
<xs:element name="myelements">
<xs:complexType>
<xs:sequence>
<xs:element name="nonboth" type="xs:string"/>
<xs:element minOccurs="0" name="minzero" type="xs:int"/>
<xs:element name="nilint" nillable="true" type="xs:int"/>
<xs:element name="nilstring" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="minzeronil" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
Just ignore the meaning of what nillable and minOccurs attributes for now. You can safely say the following XML is valid for the above Schema.
<myelements>
<nonboth>i can't be either nil nor skipped<nonboth>
Ïà¹ØÎĵµ£º
WebService£¬¼òµ¥Ò»µã˵£¬¾ÍÊǸö¶ÔÍâµÄ½Ó¿Ú,ÀïÃæÓк¯Êý¿É¹©Íⲿ¿Í»§µ÷ÓÃ(×¢Òâ:ÀïÃæÍ¬ÑùÓпͻ§²»¿Éµ÷Óõĺ¯Êý).¼ÙÈôÎÒÃÇÊÇ·þÎñ¶Ë,ÎÒÃÇдºÃÁ˸öwebservice,È»ºó°ÑËü¸øÁ˿ͻ§(ͬʱÎÒÃǸøÁËËûÃǵ÷ÓùæÔò),¿Í»§¾Í¿ÉÒÔÔÚ´Ó·þÎñ¶Ë»ñÈ¡ÐÅϢʱ´¦ÓÚÒ»¸öÏà¶Ô͸Ã÷µÄ״̬.¼´Êǿͻ§²»Á˽â(Ò²²»ÐèÒª)Æä¹ý³Ì,ËûÃÇÖ»»ñÈ¡Êý¾Ý. Webservice´«µ ......
ÉùÃ÷¶ÔÏóʵÀý
var xmlhttp = false;
//²úÉúÒ»¸öXMLHttpRequest¶ÔÏóʵÀý
getHTTPRequestObject();
function getHTTPRequestObject()
{
try
{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
xmlhttp = new ActiveXObject("Micr ......
public string GetPage(int page, int pages, string url)
{
if (pages == 0)
{
&n ......