Tài liệu Module 2: Basic XML docx

36 494 0
Tài liệu Module 2: Basic XML docx

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Module 2: Basic XML Contents Overview Lesson: The Form of XML Lesson: Designing an XML Vocabulary 13 Lesson: Namespaces 17 Lab 2: Designing an XML Vocabulary 25 Review 28 Information in this document, including URL and other Internet Web site references, is subject to change without notice Unless otherwise noted, the example companies, organizations, products, domain names, e-mail addresses, logos, people, places, and events depicted herein are fictitious, and no association with any real company, organization, product, domain name, e-mail address, logo, person, places or events is intended or should be inferred Complying with all applicable copyright laws is the responsibility of the user Without limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property  2001 Microsoft Corporation All rights reserved Microsoft, MS-DOS, Windows, Windows NT, ActiveX, BackOffice, bCentral, BizTalk, FrontPage, MSDN, MSN, Netshow, PowerPoint, SharePoint, Visio, Visual Basic, Visual C++, Visual C#, Visual InterDev, Visual Studio, Windows Media, and Xbox are either registered trademarks or trademarks of Microsoft Corporation in the U.S.A and/or other countries The names of actual companies and products mentioned herein may be the trademarks of their respective owners Module 2: Basic XML Instructor Notes Presentation: 45 Minutes This module defines Extensible Markup Language (XML) through a functional description and review of its formal requirements Lab: 45 Minutes After completing this module, participants should be able to: ! Create a well-formed XML document ! Find and fix errors of form in an XML document ! Create an XML vocabulary that meets a set of business requirements ! Use namespaces to establish a context for an XML vocabulary Materials and Preparation This section provides the materials and preparation tasks that you need to teach this module Required Materials To teach this module, you need the following materials: ã Microsoftđ PowerPointđ file 2500A_02.ppt Preparation Tasks To prepare for this module: ! Read all of the materials for this module ! Complete all practices ! Complete the demonstrations ! Complete the lab This module contains code examples that are linked to text hyperlinks at the bottom of PowerPoint slides These examples enable you to teach from code examples that are too long to display on a slide All the code examples for this module are contained in one htm file Participants can copy the code directly from the browser or from the source, and paste it into a development environment To display a code sample, click a text hyperlink on a slide Each link opens an instance of Microsoft Internet Explorer and displays the code associated with the link At the end of each example, a link displays a table of contents of all examples in this module After you finish teaching the code for an example, close the instance of the browser to conserve resources iii iv Module 2: Basic XML Recommended Reading Be ready to explain basic XML terminology Consult the following references, and give special attention to key definitions: ! The World Wide Web Consortium (W3C) Recommendation XML 1.0 ! The W3C Recommendation Namespaces In addition to consulting the W3C specifications, you should browse articles and book chapters for explanations on: ! Well-formed XML ! Processing instructions ! XML namespaces ! XML vocabularies ! Encoding schemes, such as Unicode A good place to start is Microsoft MSDN® online at http://msdn.microsoft.com/xml Module 2: Basic XML Module Strategy Use the following strategy to present this module: ! The Form of XML Explain the rules of form that govern well-formed XML ! Designing an XML Vocabulary This lesson can help you to prepare to explain the next lesson, which is about namespaces, and the next module, which is about validation ! Namespaces This module provides a very basic introduction to the idea of namespaces Most of the time, learners have trouble understanding two points regarding namespaces The first point of difficulty comes in understanding situations that require their use The lesson provides a concrete example of why you might need to differentiate one element name from another in the context of combining data from two separate XML sources This is probably good enough to get you through this lesson You will see in subsequent modules plenty of examples of namespaces, especially in the chapter on XSLT The second point that learners have trouble understanding is the logic behind why a URI is used Again, the lesson supplies a discussion on URI usage in namespaces You should point to other examples of URIs in subsequent chapters to make sure students understand this important idea v Module 2: Basic XML Overview ! The Form of XML ! Designing an XML Vocabulary ! Namespaces *****************************ILLEGAL FOR NON-TRAINER USE****************************** This module covers some of the basic ideas of XML: the rules that govern the form of XML, designing your own mark up vocabulary, and the use of namespaces Objectives After completing this module, you will be able to: ! Create a well-formed Extensible Markup Language (XML) document ! Find and fix errors of form in an XML document ! Create an XML vocabulary that meets a set of business requirements ! Use a default or an explicit namespace Module 2: Basic XML Lesson: The Form of XML ! Parts of an XML Document ! What Is Well-Formed XML? ! Rules for Elements ! Rules for Attributes ! Processing Instructions ! Comments ! How to Handle Reserved Characters *****************************ILLEGAL FOR NON-TRAINER USE****************************** Introduction In this lesson, you will examine the rules that govern the form of XML Understanding these rules will help you to create your own XML documents, and provides a foundation for further learning Lesson objectives By the end of this lesson, you will be able to: ! Identify and fix errors of form in an XML document ! Create an XML file that is well-formed ! Mark up comments and special characters so that an XML processor can process them Module 2: Basic XML Parts of an XML Document Processing instructions Elements Root element Child elements Attributes Comments Mercury Mercury Venus Venus > *****************************ILLEGAL FOR NON-TRAINER USE****************************** Introduction This topic describes the key parts of an XML document Processing instruction Most XML documents begin with an instruction to the XML processor Here, the XML processor is instructed that the document is formed according to the World Wide Web Consortium (W3C) XML Recommendation version 1.0 Elements A set of nested elements usually comes after the processing instruction An element usually consists of a start tag and a closing tag pair Between the start tag and closing tag pair, an element may contain data content or other elements An element may consist of just the closing tag The first element that the XML processor encounters must consist of a start tag and a closing tag This first element contains all other elements and is called the root element All other elements within the root element are called child elements Any child element may nest subsequent child elements Most of the content data in XML is stored between the start tag and closing tag of child elements Attributes Any element can contain attributes Using attributes is an alternative to using elements to store content You create an attribute in the start tag of an element You declare the name of the attribute, followed by a value assignment You can use either single or double quotation marks to set an attribute’s value Comments Comments are optional If a comment is well-formed, it is ignored by the XML processor Module 2: Basic XML What Is Well-Formed XML? ! XML is well-formed when it conforms to specification ! An XML error stops the XML processor Well-Formed XML 22 22 Not Well-Formed XML 22 22 XML XML Processor Processor Application Application 22 22 Error! Error! Closing Closingtag tag‘temp’ ‘temp’ does doesnot notmatch matchthe the start tag ‘Temp’ start tag ‘Temp’ Line 1, Position 11 Line 1, Position 11 *****************************ILLEGAL FOR NON-TRAINER USE****************************** Introduction For an XML document to be processed and shared between applications, it must be formed according to a rigid set of rules An XML document that conforms to a set of rules is said to be well-formed The current rules that govern the form of XML are stated in the W3C Recommendation entitled XML 1.0 XML processors and applications The XML 1.0 Recommendation differentiates an XML processor from an application An XML processor is any software that reads XML so that you can access the document content and structure XML processors are also called parsers An example of an XML processor is the Microsoft XML Core Services (MSXML) version 4.0 or MSXML4.dll Microsoft Internet Explorer is not an XML processor It is an application, because it relies on the MSXML processor to handle XML For example, white space consists of space characters, line feeds, and tabs XML processors preserve white space When you use Internet Explorer to open an XML file that contains extra white space, you notice that much of the white space is gone What happened to the white space? Internet Explorer, the application, removed the white space that was sent to it by MSXML, the XML processor XML errors When an application calls an XML processor to open a document that is not well-formed, the processor stops and reports an error to the application When Internet Explorer receives an error message from the MSXML processor, it displays an error message This feature helps you debug errors in XML documents ... ignored by the XML processor 4 Module 2: Basic XML What Is Well-Formed XML? ! XML is well-formed when it conforms to specification ! An XML error stops the XML processor Well-Formed XML 22... line in an XML document You use the XML declaration to state the version of XML that the document conforms to Currently there is only one XML version, XML 1.0 10 Module 2: Basic XML How to specify... instructions ! XML namespaces ! XML vocabularies ! Encoding schemes, such as Unicode A good place to start is Microsoft MSDN® online at http://msdn.microsoft.com /xml Module 2: Basic XML Module Strategy

Ngày đăng: 10/12/2013, 16:15

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan