Appendix A-XML and XML Schema.ppt
《Appendix A-XML and XML Schema.ppt》由会员分享,可在线阅读,更多相关《Appendix A-XML and XML Schema.ppt(35页珍藏版)》请在麦多课文档分享上搜索。
1、Appendix A: XML and XML Schema,Service-Oriented Computing: Semantics, Processes, Agents Munindar P. Singh and Michael N. Huhns, Wiley, 2005,Appendix A,2,Service-Oriented Computing: Semantics, Processes, Agents - Munindar Singh and Michael Huhns,Highlights of this Chapter,XML and Vocabularies Well-Fo
2、rmedness Namespaces and Qualified Names XML Extensions XML Schema XML Query Languages XPath XSLT Limitations,Appendix A,3,Service-Oriented Computing: Semantics, Processes, Agents - Munindar Singh and Michael Huhns,Brief Introduction to XML,Basics Parsing Storage Transformations,Appendix A,4,Service-
3、Oriented Computing: Semantics, Processes, Agents - Munindar Singh and Michael Huhns,Markup History,None Ad hoc tags SGML (Standard Generalized Markup L): complex, few reliable tools HTML (HyperText ML): simple, unprincipled, mixes structure and display XML (eXtensible ML): simple, yet extensible sub
4、set of SGML to capture new vocabularies Machine processible Comprehensible to people: easier debugging,Appendix A,5,Service-Oriented Computing: Semantics, Processes, Agents - Munindar Singh and Michael Huhns,XML Basics and Namespaces, Optional text also known as PCDATA,Appendix A,6,Service-Oriented
5、Computing: Semantics, Processes, Agents - Munindar Singh and Michael Huhns,Parsing and Validating,An XML document maps to a parse tree. Each tag ends once: nesting structure (one root) Each attribute occurs at most once; quoted string Well-formed XML documents can be parsed Applications have an expl
6、icit or implicit syntax for their particular XML-based tags If explicit, may be expressed in DTDs and XML Schemas Best referred to definitions elsewhere XML Schemas, expressed in XML, are superior to DTDs When docs are produced by external components, they should be validated,Appendix A,7,Service-Or
7、iented Computing: Semantics, Processes, Agents - Munindar Singh and Michael Huhns,XML Schema,A data definition language for XML: defines a notion of schema validity Same syntax as regular XML documents Local scoping of subelement names Incorporates namespaces Types Primitive (built-in): string, inte
8、ger, float, date, Primitive (built-in): ID (key), IDREF (foreign key) simpleType constructors: list, union Restrictions: intervals, lengths, enumerations, regex patterns, Flexible ordering of elements Key and referential integrity constraints,Appendix A,8,Service-Oriented Computing: Semantics, Proce
9、sses, Agents - Munindar Singh and Michael Huhns,XML Schema: complexType,Specifies types of elements with structure: Must use a compositor if 1subelements Subelements with types Min and max occurrences (default 1) of subelements Elements with text content not easy: ignore EMPTY elements: easy. Exampl
10、e?,Appendix A,9,Service-Oriented Computing: Semantics, Processes, Agents - Munindar Singh and Michael Huhns,XML Schema: Compositors,Sequence: ordered Can occur within other compositors Allows varying min and max occurrence All: unordered Must occur directly below root element Max occurrence of each
11、element is 1 Choice: exclusive or Can occur within other compositors,Appendix A,10,Service-Oriented Computing: Semantics, Processes, Agents - Munindar Singh and Michael Huhns,XML Schema: Key Namespaces,http:/www.w3.org/2001/XMLSchema Conventional prefix: xsd Terms for defining schemas: schema, eleme
12、nt, attribute, The tag schema has an attribute targetNamespace http:/www.w3.org/2001/XMLSchema-instance Conventional prefix: xsi Terms for use in instances: schemaLocation, null targetNamespace: user-defined,Appendix A,11,Service-Oriented Computing: Semantics, Processes, Agents - Munindar Singh and
13、Michael Huhns,XML Schema Instance Doc, Define null values as ,Appendix A,12,Service-Oriented Computing: Semantics, Processes, Agents - Munindar Singh and Michael Huhns,Creating Schema Docs: 1,Included into the same namespace as the including space.,Appendix A,13,Service-Oriented Computing: Semantics
14、, Processes, Agents - Munindar Singh and Michael Huhns,Creating Schema Docs: 2,Use imports instead of include Specify namespaces from which schemas are to be imported Location of schemas not required and may be ignored if provided,Appendix A,14,Service-Oriented Computing: Semantics, Processes, Agent
15、s - Munindar Singh and Michael Huhns,Document Object Model (DOM),Basis for parsing XML, which provides a node-labeled tree in its API Conceptually simple: traverse by requesting tag, its attribute values, and its children Processing program reflects document structure Can edit documents Inefficient
16、for large documents: parses them first entirely to build the tree even if a tiny part is needed,Appendix A,15,Service-Oriented Computing: Semantics, Processes, Agents - Munindar Singh and Michael Huhns,DOM Example Simeoni 2003,Element s = d.getDocumentElement(); NodeList l = s.getElementsByTagName(“
17、member”); Element m = (Element) l.item(0); int code = m.getAttribute(“code”); NodeList kids = m.getChildNodes(); Node kid = kids.item(0); String tagName = (Element)kid).getTagName(); ,Appendix A,16,Service-Oriented Computing: Semantics, Processes, Agents - Munindar Singh and Michael Huhns,Simple API
18、 for XML (SAX),Parser generates a sequence of events: startElement, endElement, Programmer implements these as callbacks More control for the programmer Processing program does not reflect document structure,Appendix A,17,Service-Oriented Computing: Semantics, Processes, Agents - Munindar Singh and
19、Michael Huhns,SAX Example Simeoni 2003,class MemberProcess extends DefaultHandler public void startElement (String uri, String n, String qName, Attributes attrs) if (n.equals(“member”) code = attrs.getValue(“code”);if (n.equals(“project”) inProject = true;buffer.reset(); public void endElement (Stri
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- APPENDIXAXMLANDXMLSCHEMAPPT
