To talk about these W3C languages or standards, they must all start with the HTML language. I am no exception, and because HTML is simple and easy to understand (of course, it is very difficult to extend it 10 years ago), for these Markup languages such as XML, I don't care too much. recently, there is a module in the project, which is a normal Web page capture. Then, we use XPath to analyze the HTML Script and save the required results in XML, in this way, the data and display are separated, and then different XSLT are used for Conversion Based on the client to generate HTML scripts corresponding to the device for browsing.
It can be seen that many Markup languages are involved, so today I plan to give a rough introduction to this knowledge. in my personal opinion, unless it is necessary to use it immediately, it is enough to have a taste of it. I have learned about the system in w3schools. Here is a brief introduction.
1. XSL
XSL should correspond to XML. One is to describe data and the other is to describe and process data. XSL is divided into three parts. first, XSLT is the language that represents data. 2. XPath: how to search for the Data Language. third, XSL-FO, formatting the language of the data (as you have never heard ). A special example is CSS and HTML. html is a special XML with predefined labels. CSS indicates how to display the HTML language, while the bloated definition of HTML already contains a lot of labels for displaying data, such<B> </B><I> </I>And so on.
2. XSLT
XSLT uses XPath to search XML data. The root node is <XSL: stylesheet> or <XSL: Transform>.
<XSL: template match = "/"> the element specifies the location where the conversion method defined in the template is used for conversion.
<XSL: value-of select = "..."/ > Element, where value-of indicates that the data in XML is displayed here, And the SELECT statement behind it is an XPATH statement, indicating that only the data filtered by XPath is displayed.
<XSL: For-each select = "AA [BB = 'cc']"> This element is the standard-compliant data displayed in the loop search. XPath is under the AA node, all data whose BB attribute is equal to CC.
<XSL: Sort select = "AA"/> specifies that the final data is sorted by the value of the AA node.
<XSL: If test = "Price & gt; 10"> the condition judgment element only displays the elements that meet the conditions. Pay attention to the logical judgment symbols. <,>, & gt ;,& Lt; to replace.
<XSL: Choose> <XSL: When test = "Price & gt; 10"> </XSL: When> <XSL: otherwise> </XSL: otherwise> </XSL: Choose> andProgramming LanguageIn the case... When statement, data is classified by conditions.
<XSL: Apply-templates> applies a template that meets the requirements for the current element and its child elements.
On the client side, you can use JavaScript to apply XSLT bar XML into XHTML for display. This will depend on the specifications of the client browser.
On the server, you can use ASP,. net, and other languages to use the XML function of the platform for conversion.
3. xpath
A series of other languages, XQuery, xlink, xpointer, and XSLT, depend on XPath for data retrieval. The XPath function is powerful and has built in hundreds of functions.
Nodes include document node, element node, and attribute node.
Some data retrieval syntaxes are as follows:
Expression |
Description |
Nodename |
Selects all child nodes of the named Node |
/ |
Selects from the root node |
// |
Selects nodes in the document from the current node that match the selection no matter where they are |
. |
Selects the current node |
.. |
Selects the parent of the current node |
@ |
Selects attributes |
A search statement can contain a logical judgment statement specified by [], indicating that only data that meets the conditions can be obtained.
Wildcard
Wildcard |
Description |
* |
Matches any element node |
@* |
Matches any attribute node |
Node () |
Matches any node of any kind |
Use | combines two or more path conditions. The result is the sum of the obtained results obtained separately.
XPath axis, indicating the relationship conditions between nodes.
Axisname |
Result |
Ancestor |
Selects all ancestors (parent, grandparent, etc.) of the current node |
Ancestor-or-self |
Selects all ancestors (parent, grandparent, etc.) of the current node and the current node itself |
Attribute |
Selects all attributes of the current node |
Child |
Selects all children of the current node |
Descendant |
Selects all descendants (children, grandchildren, etc.) of the current node |
Descendant-or-self |
Selects all descendants (children, grandchildren, etc.) of the current node and the current node itself |
Following |
Selects everything in the document after the closing tag of the current node |
Following-sibling |
Selects all siblings after the current node |
Namespace |
Selects all namespace nodes of the current node |
Parent |
Selects the parent of the current node |
Preceding |
Selects everything in the document that is before the start tag of the current node |
Preceding-sibling |
Selects all siblings before the current node |
Self |
Selects the current node |
XPath logic judgment
Operator |
Description |
Example |
Return Value |
| |
Computes two node-Sets |
// Book | // CD |
Returns a node-set with all book and CD Elements |
+ |
Addition |
6 + 4 |
10 |
- |
Subtraction |
6-4 |
2 |
* |
Multiplication |
6*4 |
24 |
Div |
Division |
8 Div 4 |
2 |
= |
Equal |
Price = 9.80 |
True if price is 9.80 False if price is 9.90 |
! = |
Not equal |
Price! = 9.80 |
True if price is 9.90 False if price is 9.80 |
< |
Less |
Price <1, 9.80 |
True if price is 9.00 False if price is 9.80 |
<= |
Less than or equal |
Price <= 9.80 |
True if price is 9.00 False if price is 9.90 |
> |
Greater |
Price> 9.80 |
True if price is 9.90 False if price is 9.80 |
> = |
Greater than or equal |
Price >=9.80 |
True if price is 9.90 False if price is 9.70 |
Or |
Or |
Price = 9.80 or price = 9.70 |
True if price is 9.80 False if price is 9.50 |
And |
And |
Price> 9.00 and price <9.90 |
True if price is 9.80 False if price is 8.50 |
MoD |
Modulus (Division remainder) |
5 mod 2 |
1 |
4. XQuery
XQuery uses XPath to retrieve XML data. The result is not a node set, but a sub-XML data. Similar to using SQL statements to retrieve Databases
5. xlink and xpointer
Xlink defines the basic method for adding hyperlinks to XML, and xpointer defines more targeted definitions of hyperlinks to specified XML data.