Xml Schema
Standards
"DTD" was the first formalized standard, but is rarely used anymore.
"XDR" was an early attempt by Microsoft to provide a more comprehensive standard than DTD. This standard has pretty much been abandoned now in favor of XSD.
"XSD" is currently the de facto standard for describing XML documents. There are 2 versions in use 1.0 and 1.1, which are on the whole the same (you have to dig quite deep before you notice the difference). An XSD schema is itself an XML document, there is even an a XSD schema to describe the XSD standard.
There are also a number of other standards but their take up has been patchy at best.
<xs:element/>
Sample:
<xs:element name="Customer_order" type="xs:integer" minOccurs ="0" maxOccurs="unbounded" default="unknown"|fixed=" UK"/>
Complex type
<xs:element name="Customer">
<xs:complexType>
<xs:sequence>
<xs:element name="Dob" type="xs:date" />
<xs:element name="Address" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
XML sample
<Customer>
<Dob> 2000-01-12T12:13:14Z </Dob>
<Address> 34 thingy street, someplace, sometown, w1w8uu </Address>
</Customer>
There are 3 types of compositors <xs:sequence>, <xs:choice> and <xs:all>. These compositors allow us to determine how the child elements within them appear within the XML document.
Compositor
Description
Sequence
The child elements in the XML document MUST appear in the order they are declared in the XSD schema.
Choice
Only one of the child elements described in the XSD schema can appear in the XML document.
All
The child elements described in the XSD schema can appear in the XML document in any order.
Notes
The compositors <xs:sequence> and <xs:choice> can be nested inside other
相关文档:
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
xml学习:http://www.w3school.com.cn/x.asp ......
1、初始化
Load 导入一个XML文件到CMarkup的对象中,并对它进行解析。类似C#的Load。
SetDoc 从字符串中导入XML数据,并对它解析。类似C#的LoadXml。
2、输出
Save 将XML数据写入文件中。类似C#的Save。
GetDoc 将整个XML数据文档作为字符串返回。
3、改变当前位置
FindElem 定位到下一个元素,可能和一个标签名或路 ......
XML 和 JSON 是当今常用的两种数据描述与传输的格式,特别是涉及到 JS 时使用 JSON 颇为频繁。自然,在 Java 的世界里少不了完成 JavaBean 与这两种格式相互转换的组件,那就是 XStream 和 JSON-lib。这里我简单记下 XStream 的用法。
其实相类似的工具早已有之。如果用过 DWR 的同志,一定有印像,DWR 进行远 ......
XML的四种解析器原理及性能比较 ......
今天继续讲XML,争取在下午5点前占领XML高地。一共三个主要内容:SAX解析技术,DOM4J和SCHEMA。
首先是SAX解析技术:SAX采用事件处理的方式解析XML文件。利用 SAX 解析 XML 文档,涉及两个部分:解析器和事件处理器。
解析器负责读取 XML 文档,并向事件处理器发送事件
事件处理器负责对事件做出相应,对传递的 XML 数据 ......