XML and its technical guide

xiaoxiao2021-03-06  45

XML and its technical guidelines: This article describes the techniques in XML and XML families. We will discuss how the core technologies are combined into a complete whole and some things that support XML technology. It seems that such things are happening every day: more and more developers believe that XML (Extensible Markup Language will fundamentally change our software industry. But if you want to figure out why this is or when you will happen, you will find the interpretation of the explanation of the XML. These things don't actually let you understand what, I believe that you will not satisfy the explanation like them. Typically, people have learned the main obstacles encountered when learning to grasp XML from XML amazing development speed. If you browse W3C about XML website (http://www.w4.org/xml/), you will find a lot of techniques and related publications about XML. W3C gathers such a large amount of information, causing a small trouble to developers. In the case of "How the technology used in XML is integrated", "it is difficult to learn XML in the case of clear concept. This article introduces you the techniques in the XML and XML families, making you not only understand the importance of XML at a higher level, but also know how the techniques in XML are combined to become a complete technology. After reading this article, you will have a roughly understanding of those XML dedicated nouns and their abbreviations, and lay the foundation from a deeper level learning XML in the future. So what is XML? Among the many authors of the previous XML, answering this problem has become a style. Just like you are well known, XML is an official abbreviation for Extensible Markup Language. They may think that XML pronunciation is more sexy than EML, so that the original letter E is changed to the letter X. However, when you cross the abbreviation from a deeper level, you will find it more than just a tag language, but a series of technologies. This technical family provides a solution for our development with better scalability and interoperability. Where is XML from? XML originated from SGML (STANDARD Generalized Markup Language. In other words, you can use XML or use SGML to create your own descriptive document. Both languages ​​use the text ID (Tags) to describe data for other applications or It is a tool (such as an SGML or an XML analysis program). With XML, they can read the information correctly and some interesting operations for the data. XML is a simplified version of SGML, it is more suitable for use on the Web The syntax XML of XML defines the syntax used to describe your data. One is a correct XML statement: and other identifier languages ​​are different, XML pair Size is sensitive. Therefore, element and element are different in XML. At the same time, XML will not ignore spaces (other languages ​​often ignore spaces). Confused each one may cause confusion for document structure Characters, XML will be done carefully (like ). If an XML document contains only one root element, and all child elements are properly placed in the parent element, such XML has a good style. More specifically In terms of each given child element, its Begin and End TAG are only in the same parent element.

Below is a good style XML document example (Hamburger.xml). cowburger greasy and good. 2.99 < / Hamburger> Who will define tags? After reading the previous part, you will find that you have basically learned the syntax of XML. In fact, there are not many content here, and XML is indeed very simple. Maybe you have noticed that XML looks like HTML (Hypertext Markup Language). They all use the same syntax to define Begin and End Tag and some attributes. Essentially, HTML uses some pre-set elements and methods, just a special case of XML. These elements and their related methods determine how the browser explains an XML document and is supplied to the end user. Like HTML, the XML provides a general method for describing and coordinating data. XML allows developers to create their own XML vocabulary, describe their own data structures in customized ways. If a developer is developing software for a fast food chain, then in order to describe some food, a "hamburger" element may be very convenient. Once developers use XML to describe their data, they can easily interoperate between these data in the same or different systems. Of course, the premise is those systems understand XML. For example, a developer can use data from another system as long as those data are described in XML. As a result, developers don't have to worry about all aspects such as platforms, operating systems, languages, or data storage when considering the interoperability of the software. XML is the simplest tool for implementing interoperability between systems. XML's namespace can create our own XML vocabulary due to XML's interaction, each person. In this way, if different developers use the same elements to represent different entities, consequences are unimaginable. In order to prevent this potential conflict, W3C introduces a name space in XML. XML namespace provides a context for your XML document element. It allows developers to handle elements in a certain semantic. Also explained by hamburger, in a system may represent the consumer purchase price, and in another system, it may represent the purchase price of the store. The following example demonstrates how the name space is to help us solve such a problem.

cowburger Greasy and good. 0.99 2.99 < / hamburgers> How do I use XML? XML's grammar is not difficult, but if you want to use XML, let it help us do something or have a certain challenge. To use XML, we have to program the processing XML file. W3C defines a software model called "XML processor". It is able to read an XML document and provide access to its contents and structures. Microsoft's most important XML processor is called Microsoft XML (MSXML) 2.0. MSXML 2.0 is bundled in IE 5.0, and can be used as a separate distributable file from Microsoft MSDN XML website (http://msdn.microsoft.com/xml). One main advantage of using XML as a general standard for describing data is that the functions provided by any XML processor allow us to achieve the goals we think. Developers have almost no (if you have ever done), you will write your own XML processor. In theory, developers should use the best processors on the market to avoid compatible issues. Using a standard XML processor, you can read a variety of XML documents (such as Hamburger.xml), access any elements, elements, or element properties. If you create an XML document in a Windows-based system, you can easily turn this document to the mainframe system, with the XML processor of the main machine to implement interaction with the same data. This is the real charm of XML. As a technology, XML does not solve all the problems of your software; but it has become an open effective mechanism for exchanging structured data between you and others. The core technology of XML is now now, you can completely create an XML document that belongs to you. However, XML real potential is the number of technologies it support. You do not have to use all the techniques discussed herein herein. But their appearance can help you understand how these technologies are combined as part of the entire XML policy. Confirmation Technology You already know that XML provides a complete set of flexible grammar for documents that describe the structure. Because of its flexibility, we need some way to confirm that a special type of XML document has we expects a format. For example, the following is a well-structured XML document:

This declaration tells the analyzer whether it is legal regardless of the SCHEMA in the DTD, it is legal, although MSXML 2.0 support DTDS, but you will still find that they are very laborious. It is very complicated and difficult to master and use. Note that the DTD syntax is not a legitimate XML. Because of this, the XML processor has to support DTD syntax for SCHEMA in addition to the XML syntax. Imagine, if we use XML to describe schema, the developer, especially the provider of the XML tool, will be much easier. W3C is considering several programs that make up DTDS insufficient solutions to improve the current grammar definition process. XML Data XML-DATA is an XMLSChema language. In Microsoft's definition, XML-DataSchema usually refers to Xmlschema, not Dtdschema. An XML-DataSchema is an XML document with a good structure. The XML-Data language is based on XML-Data DTD, which indicates the desired Schema definition format. Because XML-DataSchema is a simple XML document, any tool for an XML document can be used to define XML-DataSchema. The following XML-DataSchema generated SCHEMA is the same as the schema defined by Hamburger.dtd:

< Element type = "price" maxoccurs = "1" /> During the XML-DataSchema defines the and elements, respectively. They provide definitions for elements and attribute types. Use the or tab when defining an element or attribute. You can specify the number of elements allowed by defining minoccurs / maxoccurs. The SchemAxML structure also defines the location that the element allows for an Element in the XML document (for example, a element can contain several elements, etc.). Microsoft provides support for XML-DATA through MSXML 2.0. According to Microsoft's XML SDK document, the XMLschema bundled in IE 5 basically relies on XML-Data Note released in W3C in January 1998. It provides support for XML-DATA subsets, which although the syntax of XML is slightly different, just directly with the functions clarified in DCD. Processor (API) Technology We have already mentioned in front, in order to effectively use XML, you must access data by programming. We use a software module that can access the XML document to provide access to its contents and data structures, called an XML processor or an XML API. Although developers have completely free to develop or use their own XML API, I still recommend them using industry standard APIs from their own interests.

Because only the APIs accepted by the industry standard, the code written by developers can be successfully implemented in other environments without modification. There are currently two major APIs that have been widely used by the developers, which is about to become future industry standards. They are: DOM (Document Object Model) and SAX (Simple API for XML). The DOM Document Object Model Document Object Model is a standard for accessing data and structures in XML documents by programming. W3C has agreed to list it as a recommendation object of the first grade specification of future industry standards. The DOM is a tree structure based on XML document in memory. When an XML file is loaded into the processor, a corresponding tree is established in memory (see Figure 1). The DOM also defines a programming interface to travers an XML tree and manages each element, a value, and attribute (including the name and attribute name). Figure 1. XML In-Memory Representation MSXML 2.0 Fully supports DOM and provides an easy-to-use object model interact with memory tree. Here is a simple VB example, which demonstrates how to use MSXML to traverse all child elements of a tree.

Set xmlDoc = CreateObject ( "MSXML.DOMDocument") bSuccess = xmlDoc.load ( "hamburger.xml") If bSuccess Then For Each node in xmlDoc.documentElement.childNodes val = node.text NextEnd If SAX DOM standard is a major drawback is that The overall XML document is loaded into the huge overhead caused by memory. This will bring us some problems when the amount of data is very large. When you transfer such a huge XML file on the internal network or the Internet, you may wait until all file transfer ends to process data. Many XML developers have realized this, so they work together (starting with the XML-DEV mailing list) to start to create another new standard. This is SAX. Although SAX is still in the early stages of development, because of its outstanding performance, it is quickly welcomed. SAX is a very simple XML API (like its name, Simple API for XML), which allows developers to use event-driven XML parsing. Unlike DOM, SAX does not require to load the entire XML file into memory. Its idea is very simple. Once the XML processor completes the operation of the XML element, it immediately invokes a customization of an event processor to process this element and related data. Although this can greatly improve efficiency, it will also cause a certain issue. For example, developers will have to be restricted in flexibility. If you want to know more detailed information, please visit http://www.megginson.com/sax/sax.html. Conversion Technology Once you start using a standard DOM API to implement the interaction of XML data, you will find that whether to get a specific data from a large document, or convert a part of an XML document to another. Format data (such as HTML) is very monotonous. For example, if you want to find all Lowfat Hamburger Price elements. In order to complete this with a standard DOM API, you must write the code through the code through the handwriting area to find qualified elements (in this example, the condition refers to the price element of Lowfat = YES in the HANBurger element). Look at another example, suppose you want to convert the Hamburger elements used and related data into a simple HTML form for user interaction. With standard DOM API, you have to manually pass through the entire tree to get the data you need in the HTML table. I recommend the work you need to do for standardization and simplifying people to complete these tasks, W3C recommends using XSL (Extensible Stylesheet Language) and a simple query language called XSL Patterns. XSL Patterns a mode is a string that selects nodes in the XML tree by it. Such option depends on the current node connected to the mode. The name of the element is the simplest mode, this mode selects all the child nodes with the name of the current node. For example, Hamburger mode selected all Hamburger child nodes of the current node. The syntax of the pattern is very complete. It allows you to identify a context in which a specified element is in the document (for example, the Price element is in the Hamburger element), and it also provides a powerful filter syntax, which can identify nodes that meet the given conditions (for example Lowfat = yes).

In order to find all Lowfat Hamburger Price elements in a Hamburgers element, you can use the following mode strings: / hamburgers / hamburger [@ lowfat = "yes"] / price When a pattern is applied to a given node, It only returns a list of nodes that meet the specified mode. This greatly simplifies the developer's operation and no longer needs to traverse the whole tree. MSXML 2.0 The definition of the model syntax support and the definition of 2.6 in Extensible Stylesheet Language (December 18th Working Draft) is the same. The IXmldomnode interface in MSXML 2.0 provides two ways, selectnodes and selectsinglenode. Both methods are parameters as a pattern string. For example, the following line of code will return all Price nodes that meet the conditions. Set nodelist = rootnode.selectnodes ("Hamburger") XSL XSL schema helps us identify some nodes in the XML document, but the operation of these nodes is still delayed Developers are completed. XSL can help us simplify the process of completing the usual XML task: transforming the XML node from a format to another. This demand for formatting originated from Web developers need to convert their XML data into HTML data for users to browse. In fact, XSL can do much more than the above description. XSL can effectively define conversions between an XML format to another XML format, which greatly enhances interoperability. If a person sends an XML document to your system, your system does not know the XML vocabulary it uses, you can get the words you are familiar with once a simple XSL conversion. It is because of this simple feature of XML, developers do not have to use universal vocabulary to describe some type of data. An XSL file contains a series of declaration templates for defined conversion rules. Each template clearly defines how to convert the specified nodes in the source document into the node (or other type of data) in the output document. You can use XSL mode to determine a template to apply those parts in a document. As an example, the Hamburger XML file is converted below:

cowburger greasy and good. 2.99 < / Hamburger> Convert to HTML files:

Hamburgers
  1. cowburger, $ 2.99, greasy and good. The XSL file you use is as follows :

    < Body>

    Hamburgers
  2. , , Notice, how do we use the XSL mode to identify element sets in the Match and SELECT properties of different XSL elements? Define a set of conversion rules for a set of nodes in the tag. Xi It is very interesting to define the process of defining the conversion using a standard XML vocabulary. The link technology believes that HTML is really strong in its anchor element. Xpointer In the previous chapter, XLINK needs to rely on different mechanisms to identify you To link resources (such as a unified resource identifier). W3C introduces another mechanism called XPointer for constructing an internal structure of an XML document. Specifically, it determines whether an element in an XML document, a string or other part has a specific identifier. An XPointer includes a series of terms of a series of descriptions, any of them specifies a particular location information, usually associated with location information specified by the previous term. Each position term has a keyword (for example, ID, child, network, etcor, etc.) and several variables, such as serial numbers, element types, or properties of the instance. Look at the following example: Child (2, hamburger means the element of the second type Hamburger. Other XML-related technologies and vocabulary currently we have talked about the core technology of XML. You may think that these things are enough, but if we don't go deep into some introduced XML related technologies and words under the moment, this article explores the XML's article is not very complete. Currently, these new technologies are working next step by step by step by step. Mathml (Mathematical Markup Language) Mathml is an XML application used to describe mathematical symbols, record their structure and content. Mathml's goal is to process mathematical issues on the web. Like HTML processing text. The following is a Mathml example provided by W3C. Mathematical equation: X2 4X 4 = 0 can be represented by the following XML vocabulary in Mathml: x 2 4 x 4 smil smil (Synchronized MultiMedia Integration Language, its pronunciation and "smile" are a language based on XML-based multimedia demo. SMIL allows a set of independent multimedia objects to be integrated into a multimedia presentation. As another industry trend, HTML TIME relies on SMIL to add multimedia Time feature in your HTML page. IE 5 now provides an implementation of HTML TIME. A time series is included in the page in the following example. Each P element in the time period will appear after the previous P element disappears.