Xml
For example, if you want to find all the lowfat hamburger price elements. To do this with the standard DOM API, you must traverse the entire tree by hand writing code to find the element that matches the condition (in this case, the condition refers to the price element that is lowfat=yes in the Hanburger element). Let's look at another example, assuming you want to convert the hamburger elements and associated data into simple HTML tables for users to interact with. Using the standard DOM API, you have to manually traverse the entire tree to get the data you need in the HTML table.
In order to standardize and simplify the work that people do to accomplish these tasks, the Consortium recommends using XSL (extensible Stylesheet Language) and a simple query language called XSL patterns.
XSL Patterns
A pattern is a string that selects nodes in an XML tree. This selection depends on the current node to which the pattern is connected. The name of the element is the simplest pattern, which selects all child nodes of the current node that have that name. For example, the hamburger mode selects all hamburger subnodes of the current node.
The syntax of the pattern is very complete. It allows you to identify the context in which a given element is in the document (for example, the price element is in the hamburger element), and it also provides a powerful filtering syntax that allows us to identify nodes that meet a given condition (for example, Lowfat=yes). To find all the lowfat hamburger price elements in a hamburgers element, you can use the following pattern string:
/hamburgers/hamburger[@lowfat = "Yes"]/price
When a pattern is applied to a given node, it returns only the list of nodes that match the specified pattern. This greatly simplifies the developer's operation and no longer requires traversing the entire tree.
The support for the schema syntax in MSXML 2.0 is identical to the definition of section 2.6 in Extensible Stylesheet Language (December 18th Working Draft). The IXMLDOMNode interface in MSXML 2.0 provides two methods, SelectNodes and selectSingleNode. Both methods use a pattern string as a parameter. For example, the following line of code returns all the price nodes that meet the criteria.
Set nodelist = Rootnode.selectnodes ("hamburger[@lowfat =" yes "]/price")
Xsl
XSL patterns can help us identify certain nodes in a given XML document, but the operations of these nodes ultimately depend on the developer to complete them. XSL can help us simplify the process of accomplishing the usual XML tasks: Transforming an XML node from one format to another. This need for format conversion originates from the need for Web developers to convert their XML data into HTML data for users to browse.
In fact, the XSL can do far more than the description above. XSL can effectively define conversions from one XML format to another, which greatly enhances interoperability. If someone sends an XML document to your system and your system does not recognize the XML vocabulary it uses, you can get a familiar word by simply making a simple XSL transformation. It is the simple nature of XML that makes it easier for developers to use generic terms to describe some type of data.
An XSL file contains a series of declarative templates that define the transformation rules. Each template explicitly defines how to convert a specified node in a source document to a node (or other type of data) in the output document. You can use XSL mode to determine which parts of a document a template applies to.
As an example, the following transforms the hamburger XML file:
<?xml version= "1.0"?>
<name>CowBurger</name>
<description>greasy and Good.</description>
<price>2.99</price>
Convert to HTML file:
<body>
<ol>
<li>cowburger, $2.99, greasy and good.</li>
</ol>
</body>
The XSL file you use is as follows:
<?xml version= "1.0"?>
<xsl:stylesheet xmlns:xsl= "Http://www.w3.org/TR/WD-xsl" >
<xsl:template match= "/" >
<body>
<xsl:for-each select= "hamburgers[@lowfat =" Dream On "]>
<li><xsl:value-of select= "Name"/>, <xsl:value-of select= "Price"/>
<xsl:value-of select= "description"/></li>
</xsl:for-each>
</body>
</xsl:template>
</xsl:stylesheet>
Did you notice how we used the XSL pattern to identify the set of elements in the match and select attributes of different XSL elements? The conversion rules for a set of nodes are defined in the <xsl:template> tab. Is it interesting that XSL uses a standard set of XML words to define the process of conversion?
Link Technology
Many people think that the real strength of HTML lies in its anchor elements.
<a HREF = "http://www.someserver.com" >some link</a>
Anchor elements allow developers to create links from one HTML page to another, defining the relationship between two documents. This provides a way for users to get more relevant data from the current page. At the same time, this is a typical method used by users in querying data. In order to find the data, they browse a page, and they may find something more consistent with their requirements in this page. And the content is stored on different pages through a link.
The entire web is based on such a cornerstone of establishing relationships (links) between different data files. As the IT industry continues to evolve, it is natural to think of similar mechanisms to describe the links between different XML documents or different elements in the same document.
Xlink
XML linking 1.0 (XLink) is the syntax for the consortium-led definition of XML links. According to the requirements of the XLink 1.0 document, an XML link, or xlink descriptive information, explicitly specifies the relationship between a resource or a portion of the resource. In XLink, we do not involve methods that mark the locations of different types of data (such as URIs, Xpointers, and graphics coordinates).
Here is a simple example of an XML connection:
"Http://fastfood.org/hamburger.asp" >
XPointer
As you've read in the previous chapters, XLink needs to rely on different mechanisms to identify the resources you want to link (such as the Uniform Resource Identifier). The consortium has introduced another mechanism called XPointer to construct the internal structure of an XML document. Specifically, it determines whether an element, string, or other part of an XML document has a specific identity.
A xpointer includes a list of terms that describe the location, and any one of them specifies a specific location information that is always associated with location information specified in the previous term. Each location term has a keyword (such as id,child,ancestor, and so on) and several variables, such as the serial number of the instance, the element type, or the attribute. Look at the following example:
Child (2,hamburger)
Refers to the second element with a hamburger type.
Other XML-related technologies and terminology
What we've talked about so far has represented the core technology of XML. Maybe you think these things are enough, but if we don't go deeper into some of the popular XML-related technologies and vocabulary, this article looks at the XML article as incomplete. Currently, these new technologies are maturing in the efforts of the development teams of the consortium.
MathML (mathematical Markup Language)
MathML is an XML application that describes mathematical symbols and records their structure and content. The goal of MathML is to implement a mathematical problem on the web, like HTML processing text. The following is an example of the MathML provided by the consortium. Mathematical equation:
X2 + 4x + 4 =0
In MathML, you can use the following XML vocabulary to represent:
<apply>
<plus/>
<apply>
<power/>
<ci>x</ci>
<cn>2</cn>
</apply>
<apply>
<times/>
<cn>4</cn>
<ci>x</ci>
</apply>
<cn>4</cn>
</apply>
Smil
SMIL (Synchronized Multimedia Integration Language, whose pronunciation is the same as "Smile") is an xml-based language for presenting multimedia presentations. SMIL allows the integration of a set of independent multimedia objects into a multimedia demo. As another industry trend, Html+time relies on the SMIL feature to add multimedia "time" features to your HTML pages. Now IE 5 provides a html+time implementation. The page in the following example contains a time series. Each P element that is in a time period waits until the previous P element disappears before it appears.