XML is a set of rules that define semantic tags, which divide a document into many parts and identify them. It is also a meta-markup language, that is, a syntactic language that defines other semantic and structured markup languages related to a specific domain.
XML is a meta-markup language.
The first thing to understand about XML is that it is not just like Hypertext Markup Language (HTML) or formatter. These languages define a set of fixed tags to describe a certain number of elements. If the markup language does not have the required markup, users will be powerless. At this time, we have to wait for the next version of the markup language, hoping to include the required tags in the new version, but this will depend on the choice of software developers.
But XML is a meta-markup language. Users can define their own labels. These labels must be created according to some general principles, but they are also quite flexible in the sense of labels. For example, if the user is dealing with things related to genealogy, it is necessary to describe birth, death, burial place, family, marriage, divorce, etc. , it is necessary to create a label for each item. The newly created tag can be described in a document type definition (DTD). In the second part of this book, you will learn more about DTD. Now, just think of DTD as a vocabulary and the grammar of a document. For example, Moore's Law. The DTD file in Peter Murray-Rust's Chemical Markup Language (CML) describes the vocabulary and grammar of molecular science, including chemistry, crystallography and solid-state physics. It includes labels of atoms, molecules, bonds, spectra, etc. This DTD can be shared with many different people in the field of molecular science. There are other DTDs for other fields, and users can also create their own DTDs.
XML defines a set of meta-grammars, which must follow domain-specific markup languages, such as MusicML, MathML, cML, etc. If an application can understand this meta-grammar, then it can automatically understand all languages established by this meta-language. Browsers don't have to know every tag used by many different markup languages in advance. In fact, when a browser reads a document or its DTD, it only knows the tags used in a given document. Another style sheet attached to the document provides detailed instructions on how to display these markup contents. For example, consider the Schrodinger equation:
Scientific papers are full of such equations, but scientists have to wait for many years before browser developers can support the tags needed to write the most basic mathematical formulas. Musicians have the same restrictions, because neither Netscape Navigator nor Internet Explorer supports music scores.
With XML, it means that you don't have to wait for browser developers to meet users' needs. Users can create their own tags, and when necessary, just tell the browser how to display them.
XML describes structure and semantics, not format.
The second thing to know about XML is that XML tags describe the structure and meaning of documents. It does not describe the format of page elements. Style sheets can be used to add formatting information to documents. The document itself only explains which tags the document includes, not what the document looks like.
In contrast, HTML documents include format, structure and semantic tags. Is a format tag, which makes the content bold. It is a semantic marker, which means that the content is particularly important. Is a structural label, indicating that the content is a unit in the table. In fact, some markers may have all three meanings. Tags can represent the bold, first-level title and page title of the 20-point Helvetica font at the same time.
For example, in HTML, songs can be described by defining titles, defining data, unordered lists and list items. But in fact, these projects have nothing to do with music. Songs defined in HTML may be as follows:
Sexy COP
Jacques Molari Henry Bellolo and Victor Willis
Jacques Molari
Publisher: Polaroid Records.
Length: 6:20
Written: 978
Artist: villager
In XML, the same data can be marked as:
Sexy COP
Jacques Molari
Henry Bellolo
Victor Willis
Jacques Molari
Polaroid records
twenty past six
978
villager
Meaningful tags such as,, and are used in this list instead of common tags such as and. This usage has many advantages, including that the source code is easy to read and people can understand the author's meaning.
XML tags can also make it easy for non-human robots to find all the songs in the document. In HTML, robots can only tell us that this element is dt. Robots can't decide whether dt represents the title or definition of a song, or just some indented text format that designers like. In fact, a single document can well contain various dt elements with three meanings.