易截截图软件、单文件、免安装、纯绿色、仅160KB

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"应该就是表示这个元素为空)
minOccurs="0":该元素可以直接被省略掉,但是不能让该元素的值为空,也就是说,不能:
<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>


相关文档:

解析XML时DTD的处理 解析时忽略,生成XML文件时加上


一、解析XML文件时,遇到DTD的定义要怎么办?
    下面这段代码是ibatis配置文件,用w3c Dom(其实任意一种解析方式都是这样)都会从http://www.ibatis.com/dtd/sql-map-config-2.dtd
 这
个地址找对应的DTD文件进行校验,如果因特网上这个地址不存在的话,就会报 java.net.ConnectException:
Con ......

使用dom4j读取xml文件

首先将dom4j-1.6.1.jar,jaxen-1.1.1.jar两个jar包导入到项目中
reader_config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<db-info>
<driver-name>oracle.jdbc.driver.OracleDriver</driver-name>
<url>jdbc:oracle:thin:@192.168.1.100:1521:orcl</url> ......

asp.net 输出XML文件

private void WriteXML()
{
StringBuilder sb = new StringBuilder();
sb.Append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?> ");
sb.Append(" <!-- ");
sb.Append("<content>");
sb.Append(& ......

用CMarkUp类解析XML文件

解析:
 CMarkup xml;
 CString strChanText, strChanType;
 xml.Load("MyXml.xml");
 xml.ResetMainPos();
 if (!Chan.FindElem("TreeOrg"))
 {
      return;
 }
 if (xml.IntoElem())
 {
      xml.FindEle ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号