Beginning Ajax with ASP.NET- P10
Số trang: 15
Loại file: pdf
Dung lượng: 390.21 KB
Lượt xem: 21
Lượt tải: 0
Xem trước 2 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
Beginning Ajax with ASP.NET- P10:Thank you for purchasing Beginning Ajax with ASP.NET. We know that you have a lot of options whenselecting a programming book and are glad that you have chosen ours. We’re sure you will be pleasedwith the relevant content and high quality you have come to expect from the Wrox Press line of books.
Nội dung trích xuất từ tài liệu:
Beginning Ajax with ASP.NET- P10 Data Communication: XML, XSLT, and JSON { this.lblLoadResult.Text = “Validation Error: “ + Convert.ToString(e.Message) + “”; } The XmlReaderSettings object specifies the settings used in reading in some XML. This object is used with the static .Create() method when an XmlReader object is created. The properties to note are the ValidationType, which is set from an enumeration, and the Schemas property, which is based on the SchemaSet object. The XmlSchemaSet object contains a set of XML Schemas to validate against. If the XML is not valid based on the schema, an XmlSchemaException() is generated.Parsing XML Two popular types of XML processing exist — the Document Object Model (DOM) and the Simple API for XML (SAX). The key difference between these two approaches is that the first loads the entire XML document into an in-memory data structure, whereas the latter iterates over the XML document one piece at a time in a forward-only, read-only fashion.DOM Parsing The Document Object Model (DOM) is an API that allows access to XML and HTML documents and their elements. The DOM is programming-language- and platform-independent. Typically, XML parsers have been developed that must make use of a tree structure will all elements fully loaded into the parser before any operations occur. As a result, DOM is best used for applications where the document elements are randomly accessed and manipulated. There are several levels of DOM specification. These specification levels are: ❑ Level 0 — A Level 0 DOM contains all of the vendor-specific DOMs that existed before the W3C standardization process. ❑ Level 1 — A Level 1 DOM allows for the navigation of documents and modification of their content. ❑ Level 2 — A Level 2 DOM contains support for XML namespaces, filtered views, and events. ❑ Level 3 — A Level 3 DOM consists of support for: ❑ DOM Level 3 Core ❑ DOM Level 3 Load and Save ❑ DOM Level 3 XPath ❑ DOM Level 3 Views and Formatting ❑ DOM Level 3 Requirements ❑ DOM Level 3 Validation For further information on the DOM, please refer to Chapter 3. 111Chapter 5SAX Parsing Simple API for XML (SAX) parsing is another form of processing of XML files. A SAX-based parser handles XML as a single stream of data that is available only unidirectionally. As a result, accessing previously used data will result in the XML stream being reread and reparsed. SAX processing is based on asynchronous events. In this model, as the XML document is read and parsed, events are fired as set up by the program. This is believed to result in faster XML processing than the DOM, because of a much smaller memory footprint compared to using a fully loaded and parsed DOM tree. Truthfully, the speed comparison should be based on a specific program, so generalities like this do not hold up in all situations. The other problem with SAX, which is more significant than the unidirectional issues, is the event-driven programming model. Accurately creating an event-driven program can be very complicated and frustrating.XML Summary As you have noticed, XML can be a very complicated topic. In this section, we have attempted to cover the basic topics that you need regarding what XML is, but this is not meant to be a complete reference for XML, just a set of basic information. For more complete information, please reference the books men- tioned at the beginning of the chapter. In the next section, we will look at the processing XML with a technology referred to as XSLT.XSLT Extensible Stylesheet Language Transformations (XSLT) is an XML-based language used to convert XML from one format to another. These other formats may be a different XML Schema, HTML, plain text, PDF, or some other format. XSLT grew out of the Extensible Stylesheet Language (XSL) development effort within the W3C. The XSLT specification was first published by the W3C as a recommendation on November 16, 1999.How Processing Occurs The XSLT language is declarative. Being declarative means that the XSLT stylesheet is made up of a set of templated rules. Each rule in the collection specifies what to add to the resulting output, and the result is then sent to the output. Once an XSLT processor finds a node that meets the processing condi- tions, instructions within the template rules are processed sequentially. The XSLT specification defines a transformation in terms of source and results. This keeps from locking a developer into a set of system specific APIs. XSLT uses the X Path language for identifying the appropriate data in the source tree. X Path also pro- vides a range of functions that assist XSLT processing. Now take a look at some example XSLT coding. First, consider the following sample XML:112 Data Communication: XML, XSLT, and JSON Hamburger French Fries Milk Shake 4.99 Suppose that from this code you want to pull out the elements within the tags. The followingXSLT code will pull out a list of items. This code works by looking for the matches for the tag, pulling them out, and sending them tothe output stream. With the .NET Framework, there is an XML Transform control. By setting the con-trol’s DocumentSource and TransformSource properties, the control may be used to easily output theresults of an XML file being transformed by an XSLT file. The result of this XML file b ...
Nội dung trích xuất từ tài liệu:
Beginning Ajax with ASP.NET- P10 Data Communication: XML, XSLT, and JSON { this.lblLoadResult.Text = “Validation Error: “ + Convert.ToString(e.Message) + “”; } The XmlReaderSettings object specifies the settings used in reading in some XML. This object is used with the static .Create() method when an XmlReader object is created. The properties to note are the ValidationType, which is set from an enumeration, and the Schemas property, which is based on the SchemaSet object. The XmlSchemaSet object contains a set of XML Schemas to validate against. If the XML is not valid based on the schema, an XmlSchemaException() is generated.Parsing XML Two popular types of XML processing exist — the Document Object Model (DOM) and the Simple API for XML (SAX). The key difference between these two approaches is that the first loads the entire XML document into an in-memory data structure, whereas the latter iterates over the XML document one piece at a time in a forward-only, read-only fashion.DOM Parsing The Document Object Model (DOM) is an API that allows access to XML and HTML documents and their elements. The DOM is programming-language- and platform-independent. Typically, XML parsers have been developed that must make use of a tree structure will all elements fully loaded into the parser before any operations occur. As a result, DOM is best used for applications where the document elements are randomly accessed and manipulated. There are several levels of DOM specification. These specification levels are: ❑ Level 0 — A Level 0 DOM contains all of the vendor-specific DOMs that existed before the W3C standardization process. ❑ Level 1 — A Level 1 DOM allows for the navigation of documents and modification of their content. ❑ Level 2 — A Level 2 DOM contains support for XML namespaces, filtered views, and events. ❑ Level 3 — A Level 3 DOM consists of support for: ❑ DOM Level 3 Core ❑ DOM Level 3 Load and Save ❑ DOM Level 3 XPath ❑ DOM Level 3 Views and Formatting ❑ DOM Level 3 Requirements ❑ DOM Level 3 Validation For further information on the DOM, please refer to Chapter 3. 111Chapter 5SAX Parsing Simple API for XML (SAX) parsing is another form of processing of XML files. A SAX-based parser handles XML as a single stream of data that is available only unidirectionally. As a result, accessing previously used data will result in the XML stream being reread and reparsed. SAX processing is based on asynchronous events. In this model, as the XML document is read and parsed, events are fired as set up by the program. This is believed to result in faster XML processing than the DOM, because of a much smaller memory footprint compared to using a fully loaded and parsed DOM tree. Truthfully, the speed comparison should be based on a specific program, so generalities like this do not hold up in all situations. The other problem with SAX, which is more significant than the unidirectional issues, is the event-driven programming model. Accurately creating an event-driven program can be very complicated and frustrating.XML Summary As you have noticed, XML can be a very complicated topic. In this section, we have attempted to cover the basic topics that you need regarding what XML is, but this is not meant to be a complete reference for XML, just a set of basic information. For more complete information, please reference the books men- tioned at the beginning of the chapter. In the next section, we will look at the processing XML with a technology referred to as XSLT.XSLT Extensible Stylesheet Language Transformations (XSLT) is an XML-based language used to convert XML from one format to another. These other formats may be a different XML Schema, HTML, plain text, PDF, or some other format. XSLT grew out of the Extensible Stylesheet Language (XSL) development effort within the W3C. The XSLT specification was first published by the W3C as a recommendation on November 16, 1999.How Processing Occurs The XSLT language is declarative. Being declarative means that the XSLT stylesheet is made up of a set of templated rules. Each rule in the collection specifies what to add to the resulting output, and the result is then sent to the output. Once an XSLT processor finds a node that meets the processing condi- tions, instructions within the template rules are processed sequentially. The XSLT specification defines a transformation in terms of source and results. This keeps from locking a developer into a set of system specific APIs. XSLT uses the X Path language for identifying the appropriate data in the source tree. X Path also pro- vides a range of functions that assist XSLT processing. Now take a look at some example XSLT coding. First, consider the following sample XML:112 Data Communication: XML, XSLT, and JSON Hamburger French Fries Milk Shake 4.99 Suppose that from this code you want to pull out the elements within the tags. The followingXSLT code will pull out a list of items. This code works by looking for the matches for the tag, pulling them out, and sending them tothe output stream. With the .NET Framework, there is an XML Transform control. By setting the con-trol’s DocumentSource and TransformSource properties, the control may be used to easily output theresults of an XML file being transformed by an XSLT file. The result of this XML file b ...
Tìm kiếm theo từ khóa liên quan:
nhập môn lập trình kỹ thuật lập trình lập trình flash lập trình web ngôn ngữ html lập trình hướng đối tượngTài liệu có liên quan:
-
Đề cương chi tiết học phần Cấu trúc dữ liệu và giải thuật (Data structures and algorithms)
10 trang 360 0 0 -
Giáo trình Lập trình hướng đối tượng: Phần 2
154 trang 315 0 0 -
Kỹ thuật lập trình trên Visual Basic 2005
148 trang 309 0 0 -
NGÂN HÀNG CÂU HỎI TRẮC NGHIỆM THIẾT KẾ WEB
8 trang 248 0 0 -
Giới thiệu môn học Ngôn ngữ lập trình C++
5 trang 222 0 0 -
101 trang 211 1 0
-
Bài giảng Nhập môn về lập trình - Chương 1: Giới thiệu về máy tính và lập trình
30 trang 188 0 0 -
Luận văn tốt nghiệp Công nghệ thông tin: Xây dựng website bán hàng nông sản
67 trang 178 0 0 -
Luận văn: Nghiên cứu kỹ thuật giấu tin trong ảnh Gif
33 trang 159 0 0 -
Giáo trình nhập môn lập trình - Phần 22
48 trang 143 0 0