Learn XML and XSL with me

xiaoxiao2021-03-06  59

First XML document

With the development of the Internet, more and more information enters the Internet, information exchange, retrieval, preservation, and reuse such an urgent need to make HTML this most commonly used markup language has become more and more stretched. HTML integrates data content and performance, modifiable, data can retrieval, and XML draws on the advantages of HTML and database, program language, and separates the content and performance, not only makes it more convenient, but also users. The exchange between data is more convenient, and it is more reusable.

XML is a meta-marker language, without many fixed tags, providing greater flexibility for web developers. When we use HTML, the tag is just a simple representation of the display, and there is no association with the contents of the representation, which is extremely inconvenient for the further processing of the document. For example, to represent your resume, use HTML representation as follows:

Name 禹 希 初 Gender Male Birthday 1977.5

Skill Database Design and Maintenance, Web Development

Here, we cannot know what its content is not known from the mark th, and if you use XML, the corresponding document (file name: personal resume .xml) can be written as follows:

初 初

Male

1977.5

Database Design and Maintenance, Web Development

Description:

Version - The version of the XML document is specified, which can only be 1.0;

Encoding - The encoding type of the XML document is specified here, which is "GB2312", which is "Simplified Chinese".

Compare two cases, using XML we can customize the mark, indicate the meaning of the content. In this way, when communicating the information on the Internet, it provides a great convenience with the computer processing document, and we will not be able to make a bulldy steering when you read the source file.

However, since XML does not display the display mode, we will see that the XML document is displayed in a manner, such as a table. Can we display a document like HTML? The answer is negative. Taking a personal resume as an example, you need to build a format file to explain the display mode of each tag, its contents are as follows (assuming the file names resume.css):

Resume {display: block;}

Name {Display: block; font-size: 120%;

Sex {Display: block; text-indent: 2em}

Birthday {display: block; text-indent: 2em}

Skill {Display: Block; Text-Indenter Description:

All of the above CSS styles, it is recommended that the reader is familiar with the relevant information, and must be used in later learning, which is not introduced by the space relationship. After establishing the file resume.css, add the following text after the first line of the personal resume .xml file:

Description:

Here, it refers to an external CSS style file, where Type specifies the style type (which is TEXT / CSS or Text / XSL), HREF specifies the file path.

Save the file and open the file in IE5.0. how about it? The format is somewhat different. It seems that it is not satisfactory, the content of the document is clear, but the display effect is much better than the document written by HTML, and the document written by XML can only display this way? !

prompt:

1. In order to better understand and master XML, it is recommended that you are familiar with HTML 4.0 and CSS 2.0 grammar; master at least one of JavaScript, VBScript; programming experience, understanding database theory and SQL can make everyone benefit when learning XML .

2. The tiba in the XML document must be paired, if it is empty mark, there must be the end "/" of the same name tag, or use this kind of text to represent an empty tag.

3. XML and the XSL documentation will be introduced next week, the attribute value must be enclosed in double quotation marks (") or single quotes (').

4. The XML document must be a good structure (XSL document is also one of the XML documents), that is, the tag must have end tags, and the tag can nest but not cross, such as

Is legal, and below

It is wrong. If the XML document is erroneous, most of them violate the rules mentioned above.

Learn XSL (2) with me (return title)

2000-05-04 · 禹 希 初 · CPCW

XSL entry

The previous period we talked about the use of CSS (laminated style sheets) to format XML documents, and its effect is not very satisfactory. In fact, CSS is used to format HTML tags, just because it is simply used in the previous example.

XML is just a data file in more, how to change it to the files like the HTML format we have seen in our daily? If we compare the XML file than the structured raw material, then XSL is better than "sieve" and "mold", and the sieve is selected from the raw materials you need, and these raw materials form the final product: HTML.

This mold is roughly like this: We first design the page of the performance, and then get the data in the XML to fill the contents "digging", and then use the XSL statement from the related data from the XML to populate. One words: this XSL is actually a "shell" of HTML, XML data utilizes this "shell" to generate "traditional" HTML.

XML is a tree structure when the XML is expanded. We refer to a custom tag in the tree structure as a node, and there is a father and son between the nodes. Layer enters.

In the case of XSL, we have to be from the raw library? ? The relevant data is extracted in XML, and the mode query language provided by XSL is used. The so-called moderative query language is the specific statement of data from the XML through the related mode matching rule expressions, namely what we say "Sieve". Refer to Microsoft's "XSL Developer Guide", we can roughly divide the pattern language into three types:

Select mode

, , and

Test mode

and

Match mode

We now introduce them.

First, select mode

The selection mode statement extracts the data from the XML, it is a simple acquisition of data, these tags have a select property, select the data of a specific node name in XML.

1,

Such as such data in XML:

Xiaoyi

Chunhua

Autumn Auto

We want to read these three author names, is it one by one to read the "Author / Name" method, can you have multiple this NAME? If there is a procedural statement to loop how good!

I think that XSL provides such a statement of program language

Use it to read these three author names as follows:

.......

<./Xsl: 201ach>

SELECT, as the name suggests: Select, it can select a particularly unique tag in XML, or you can choose some of the same tags, we call it a node set.

grammar:

Attributes:

SELECT

Inquiry the context according to the XSL style, to determine which type of node set (satisfying SELECT condition) is described using this style. As a simplified representation, if you want to format the display method of a tag in the document, you can let the SELECT equal to the marked name of this element. For example, to format the marker XML_mark, it can be used as follows:

2. ORDER-BY

Separated in a semicolon (;) as a list of sorting standards. Adding a plus number ( ) before the list element indicates that the contents of this tag are sorted as ascending order, and the reduction ration (-) represents the reverse sequence. As a simplified representation, the sort standard list is the sequence of the marker specified by SELECT, and each tag is separated between (;).

2,

mode is just selected nodes, and does not remove the value of the node. It is like a monkey just climbed to a branch of the tree. So use to pick "Victory Fruit"! grammar:

Value of the extracting node

Attributes:

SELECT is used to match the XSL model that matches the current context. Simply put, if you want to insert an XML tag somewhere (assuming is an XML_Mark tag), you can use it as follows:

or

Example:

As an example of the foregoing personal resume in the previous period, we need to make certain modifications to the document (personal resume .xml), exactly the second line of it

change into

Then create a new file: resume.xsl, its contents are as follows:

Personal Resume </ Title></p> <p></ HEAD> <body></p> <p><Xsl: for-each select = "resume"></p> <p><P /></p> <p><Table border = "1" cellspacing = "0"></p> <p><Caption Style = "Font-size: 150%; Font-Weight: Bold"></p> <p>resume</p> <p></ CAPTION></p> <p><Tr></p> <p><TH> Name </ TH> <TD> <XSL: Value-of Select = "Name" /> </ td></p> <p><TH> Gender </ TH> <TD> <XSL: Value-of SELECT = "SEX" /> </ td></p> <p><TH> Birthday </ TH> <TD> <XSL: Value-of SELECT = "Birthday" /> </ td></p> <p></ TR></p> <p><Tr></p> <p><TH> Skill </ TH> <TD COLSPAN = "5"> <XSL: Value-of SELECT = "Skill" /> </ td></p> <p></ TR></p> <p></ TABLE></p> <p></ Xsl: for-energy></p> <p></ Body></p> <p></ Html></p> <p>Complete these will let us look at the achievements of hard work, how? Good effect. More cool is still behind. Now we have further modifications to files (personal resume .xml):</p> <p>1. Add a new tag <document> before tag <resume>;</p> <p>2. Copy and paste the content between <resume> </ resume> and paste it thereafter, and end in the last use of <document>.</p> <p>3. Open the file resume.xsl in Notepad.exe, add a text after tag <HTML>: <xsl: for-each select = "document">; Add text before tag </ html>: </ xsl: for- Each>, save the file.</p> <p>4. Open the file in the browser (personal resume .xml). What did you see? Two personal resumes!</p> <p>In this way, using XML we can write a document that is separated from the style! Of course, the XSL file is more complicated than a general HTML file, but once it is completed, it can be used to format all the same kind of XML document.</p> <p>Note: If you copy the code, delete the space</p> <p>Learn XSL (3) with me (return title)</p> <p>2000-05-05 · 禹 希 初 · CPCW</p> <p>XSL template and matching mode</p> <p>After a few days ago, we learned the writing and and three XSL elements of the XHTML document, which can be written in a fairly flexible XSL document. Today, it will learn the writing of XSL templates. We all know that short documents, the program is very good, but after the size increases, its complexity is also increased faster.</p> <p>We learned <XSL: for-Each>, <XSL: Value-of>, etc., you can use them to simply format the output for XML data, but if you encounter more complex XML format output, XSL follow request Write down, one is the difficulty of design, the scalability is poor, which is not conducive to the division of labor; the other, the modification is very poor, maybe the situation will move the army, which is not conducive to maintenance. The method of modular design in the program has been applied here!</p> <p>The XSL template refers to the design of XSL into a template (block), and finally combines these templates (blocks) into a complete XSL; it is better than ship and containers, we don't pile up all the goods, but Put these containers on the ship and then put these containers on the boat. This method allows you to consider the entire XSL design from the whole, then refine some of the forms into different modules, and then design these modules, and finally integrate them together, so that the macro is combined with micro. People have nature, standardize the requirements.</p> <p>Container? ? Writing template (block): <XSL: Template></p> <p><XSL: Template></p> <p>grammar:</p> <p><XSL: Template Match = "Node-Context" Language = "Language-Name"></p> <p>Attributes:</p> <p>Match - OK to perform this template. As a simplified description, the name of the tag is used here; where the top layer template must set the match to "/" Language - determine what scripting language in this template, which is valued with the Script tag in HTML The value of the Language property is the same, the default is JScript</p> <p><XSL: Template> Use the Match property to select a node that satisfies the condition from XML, and form a template for these specific nodes form a particular output form.</p> <p>Hanging boxing box -? ? Call template (block): <XSL: Apply-Templates></p> <p><XSL: Apply-Templates></p> <p>grammar:</p> <p><Xsl: Apply-Templates Select = "pattern" Order-by = "sort-criteria-list"></p> <p>Attributes:</p> <p>SELECT - Determine what template should be performed in this context environment, that is, the template (block) established with the <XSL: Template> tag.</p> <p>ORDER-BY ─ Sort by sequencing standard, usually a sequence of submarkers</p> <p>Example:</p> <p>Take some resume as an example, in order to facilitate the handling of our hopes "Skill", it is enclosed in <Skill> </ Skill>, how many skills have, how many of this mark, after a modified individual The resume XML documentation is as follows:</p> <p><? XML Version = "1.0" encoding = "GB2312"?></p> <p><? Xml: stylesheet type = "text / xsl" href = "resume_template.xsl"?></p> <p><Document></p> <p><Resume></p> <p><Name> 初 初 </ name></p> <p><SEX> Male </ sex></p> <p><Birthday> 1977.5 </ birthday></p> <p><Skill> Database Design and Maintenance </ Skill></p> <p><Skill> Web Development </ SKILL></p> <p></ Resume></p> <p></ Document></p> <p>Then, create a new XSL file resume_template.xsl, use the form of template, and its contents are as follows:</p> <p><? XML Version = "1.0" encoding = "GB2312"?></p> <p><XSL: Stylesheet XMLns: XSL = "</p> <p>http://www.w3.org/tr/wd-xsl "></p> <p><! - Root Template -></p> <p><XSL: Template Match = "/"></p> <p><Html> <head> <title> Personal Quest </ Title> </ head></p> <p><Body></p> <p><XSL: Apply-Templates Select = "Document / Resume" /></p> <p></ Body></p> <p></ Html></p> <p></ Xsl: template></p> <p><! - Resume Template -></p> <p><XSL: Template Match = "Resume"></p> <p><Table border = "1" cellspacing = "0"></p> <p><CAPTION> Personal resume</p> <p><XSL: Eval> Formatindex (ChildNumber (this), "I") </ XSL: EVAL></p> <p></ CAPTION></p> <p><XSL: Apply-Templates Select = "Name" /></p> <p><XSL: Apply-Templates SELECT = "SEX" /></p> <p><XSL: Apply-Templates Select = "Birthday" /></p> <p><TR /></p> <p><TD> Skill </ TD> <TD COLSPAN = "5"></p> <p><Table Cellspacing = "0"></p> <p><XSL: Apply-Templates Select = "Skill" /></p> <p></ TABLE></p> <p></ Td></p> <p></ TABLE></p> <p><Br /></p> <p></ Xsl: template></p> <p><! - Name Template -></p> <p><XSL: Template Match = "Name"> <TD> Name </ TD></p> <p><TD> <XSL: Value-of /> </ TD></p> <p></ Xsl: template></p> <p><! - Gender Template -></p> <p><XSL: Template Match = "SEX"> <TD> Gender </ TD></p> <p><TD> <XSL: Value-of /> </ TD></p> <p></ Xsl: template></p> <p><! - Birthday Template -></p> <p><XSL: Template Match = "Birthday"> <TD> Birthday </ TD></p> <p><TD> <XSL: Value-of /> </ TD></p> <p></ Xsl: template></p> <p><! - Skill Template -></p> <p><XSL: Template Match = "Skill"></p> <p><TR> <TD> <XSL: Value-of /> </ TD> </ TR></p> <p></ Xsl: template></p> <p></ Xsl: stylesheet></p> <p>Save the file, open the file (personal resume .xml), the effect is satisfactory. In fact, we must do the same effect, and use the methods described in front of the previous three weeks, but you have to take it as a whole.</p> <p>In the above XSL file, we use data items such as gender, birthday, skills to write separately, and then call <XSL: Apply-Template>, so that even if you want to make a corresponding modification of these templates. The expansion is also very convenient, not in the case of interference, mixing, unclear. This kind of first, layer-by-layer refinement design method, greatly reduces the degree of complex work, and greatly reduces the generation of errors, and can achieve multiplayer collaborative design. note:</p> <p>If the different markers with the same name in the XML document, when writing a template for it, the parent mark should be used as its prefix, the format is (PARENT_MARK / CHILD_MARK).</p> <p>The template file must have a root template whose property match is "/".</p> <p>Note: If you copy source code, remove the space</p> <p>Learn XSL (4) with me (return title)</p> <p>2000-05-06 · 禹 希 初 · CPCW</p> <p>Test mode</p> <p>One of the advantages of XML technology is the selectability of the data output, ie the data output is selected. As we mentioned in front: <xsl: for-each>, <xsl: value-of> and <xsl: Apply-Template> just simple selection of nodes arriving through the "/" symbolic layer, if we There is no need for XML data, but only some of them meet some of the data, "radish green, take the required", then the condition judges <XSL: IF> and multi-conditioned judgment <xsl: choose> and <XSL : when> catering this need, if you are familiar with the programming, you will feel that they have met.</p> <p>The IF in XSL, first, introduce the syntax structure of the XSL element <xsl: if>:</p> <p><XSL: IF></p> <p>grammar:</p> <p><xsl: if expr = "script-expression" language = "language-name" test = "pattern"></p> <p>Attributes:</p> <p>Expr ─ Script language expression, the calculation result is "true" or "false"; if the result is "true", and via Test, the content (omitable this attribute) is displayed in the output.</p> <p>Language ─ The script language type of Expression in Expl attributes, with the value of the value of the Language property of the HTML tag Script, default is "JScript" TEST - source data test conditions.</p> <p>Example:</p> <p>Here, a report is an example, the file name is Report.xml, and its content is as follows:</p> <p><? XML Version = "1.0" encoding = "GB2312"?></p> <p><? xml: stylesheet type = "text / xsl" href = "report.xsl"?></p> <p><Document></p> <p><repert></p> <p><class></p> <p>Jiajia</p> <p></ class> <q1> 50 </ q1> <q2> 70 </ q2></p> <p><Q3> 30 </ q3> <q4> 10 </ q4> </ report></p> <p><report> <class></p> <p>B class</p> <p></ class> <q1> 20 </ q1> <q2> 30 </ q2></p> <p><Q3> 40 </ q3> <q4> 50 </ q4> </ report> <report> <class></p> <p>Class Class</p> <p></ class> <q1> 70 </ q1> <q2> 40 </ q2></p> <p><q3> 20 </ q3> <q4> 10 </ q4> </ report></p> <p></ document></p> <p>We use XSL templates to combine today's <xsl: if>, we write an XSL document to it, requiring quarterly production with red oriented with red, the file name is report.xsl, the content is as follows:</p> <p><? XML Version = "1.0" encoding = "GB2312"?></p> <p><XSL: Stylesheet XMLns: XSL = "</p> <p>http://www.w3.org/tr/wd-xsl "></p> <p><XSL: Template Match = "/"></p> <p><Html> <head> <title> 1999 Production statistics </ title> </ head></p> <p><Body> <XSL: Apply-Templates Select = "Document;" /> </ body></p> <p></ Html></p> <p></ xsl: template></p> <p><XSL: Template Match = "Document"></p> <p><H3> Production statistics in 1999 </ h3></p> <p><Table border = "1" cellspacing = "0"></p> <p><TH> team </ tH> <TH></p> <p>First quarter</p> <p></ TH> <TH></p> <p>Secondary quarter</p> <p></ TH></p> <p><TH></p> <p>third quater</p> <p></ TH> <TH></p> <p>Fourth quarter</p> <p></ TH></p> <p><XSL: Apply-Templates SELECT = "Report" /></p> <p></ Table></p> <p></ xsl: template></p> <p><XSL: Template Match = "Report"></p> <p><Tr></p> <p><TD> <XSL: Value-of Select = "Class" /> </ td></p> <p><TD> <XSL: Apply-Templates SELECT = "Q1" /> </ td></p> <p><TD> <XSL: Apply-Templates SELECT = "Q2" /> </ td></p> <p><TD> <XSL: Apply-Templates SELECT = "Q3" /> </ td></p> <p><TD> <XSL: Apply-Templates SELECT = "Q4" /> </ td></p> <p></ TR></p> <p></ xsl: template></p> <p><XSL: Template Match = "Q1 | Q2 | Q3 | Q4"></p> <p><! - Test the yield here, such as adding a style attribute color color, its value is RED (red) -></p> <p><xsl: if test = ". [Value () $ 15]> <xsl: attribute name =" style "> color: red </ xsl: attribute></p> <p></ xsl: if></p> <p><XSL: Value-of /></p> <p></ xsl: template></p> <p></ xsl: stylesheet></p> <p>Description:</p> <p>Q1 | Q2 | Q3 | Q4 - Mark Q1, Q2, Q3, Q3 all used this template to determine output</p> <p>$ LE $ - is "less than or equal" in the relational operator, other relationships are less than ($ LT $), greater than ($ GT $), is greater than or equal to ($ ge $), equal to ($ EQ $), not equal ($ NE $), etc.</p> <p>- ─ Represents the current tag</p> <p>[] ─ ─ Represents screening, only markers that meet the screening conditions can be selected</p> <p>Value () ─ ─XSL function, other usual XSL functions have text (), end (), index (), etc.</p> <p>Next, we will learn the additional three elements of XSL to perform multiple times of testing the same data, and generate the corresponding output according to different conditions.</p> <p>Learn XSL (5) (return title)</p> <p>2000-05-07 · 禹 希 初 · CPCW</p> <p>Choose in XSL</p> <p>In the last period, we learned the XSL element <xsl: if>, which can determine the different output forms by testing the value of XML data (I don't know if you try, actually <xsl: for-each> can also partially implement <XSL: IF > Features), but sometimes we want to test multiple conditions simultaneously with the same data, and output the corresponding results according to different conditions. Of course, we can use if, if we only have IF available. Fortunately, we have a better choice, then use <xsl: choose>. The grammar of the related elements is described below:</p> <p><Xsl: choose></p> <p>Syntax: <xsl: choose></p> <p>Attribute: None, indicating a multi-selected test start</p> <p><XSL: WHEN></p> <p>grammar:</p> <p><Xsl: when expr = "script-expression" language = "language-name" test = "pattern"></p> <p>Attributes:</p> <p>Expr ─ Script language expression, the calculation result is "true" or "false"; if the result is "true", and via Test, the content (omitable this attribute) is displayed in the output.</p> <p>Language ─ The script language type of the expression in the expr property is the same as the value of the Language property of the HTML tag script, which is default to "JScript".</p> <p>TEST - Source data test conditions.</p> <p><XSL: OtherWise></p> <p>Syntax: <XSL: OtherWise></p> <p>Attribute: None, in a multi-selected test, if there is no condition not satisfied with <xsl: when> specified, if you finally have this tag, the contents in this tag are output.</p> <p>Example:</p> <p>Here, the student transcript is an example, requiring high (> 85), generally (70 ~ 85), starting (60 ~ 69), and does not have a display score. Among them, the XML document (file name: grade.xml) is as follows: <? XML Version = "1.0" encoding = "GB2312"?></p> <p><? Xml: stylesheet type = "text / xsl" href = "grade.xsl"?></p> <p><Document></p> <p><Grade></p> <p><Name> Big fat </ name> <English> 80 </ English></p> <p><Math> 90 </ math> <chymest> 90 </ lovest></p> <p></ Grade></p> <p><Grade></p> <p><Name> Small flower </ name> <English> 98 </ glish></p> <p><Math> 70 </ math> <crymest> 85 </ lovest></p> <p></ Grade></p> <p></ Document></p> <p>In order to implement the score level, its XSL document (file name: grade.xsl) is as follows:</p> <p><? XML Version = "1.0" encoding = "GB2312"?></p> <p><XSL: Stylesheet XMLns: XSL = "</p> <p>http://www.w3.org/tr/wd-xsl "></p> <p><XSL: Template Match = "/"></p> <p><Html></p> <p><Head> <title> transcript </ title> </ head></p> <p><Body> <XSL: Apply-Templates SELECT = "Document" /> </ body></p> <p></ Html></p> <p></ Xsl: template></p> <p><XSL: Template Match = "Document"></p> <p><Table border = "1" cellspacing = "0"></p> <p><TH> Name </ TH> <TH> English </ TH> <TH> Mathematics </ TH> <TH> Chemical </ TH></p> <p><XSL: Apply-Templates SELECT = "grade" /></p> <p></ TABLE></p> <p></ Xsl: template></p> <p><XSL: Template Match = "Grade"></p> <p><Tr></p> <p><TD> <XSL: Apply-Templates SELECT = "Name" /> </ td></p> <p><TD> <XSL: Apply-Templates SELECT = "English" /> </ td> <TD> <XSL: Apply-Templates Select = "Math" /> </ td></p> <p><TD> <XSL: Apply-Templates SELECT = "Chymest" /> </ td></p> <p></ TR></p> <p></ Xsl: template></p> <p><XSL: Template Match = "Name"> <xsl: value-of /> </ xsl: template></p> <p><XSL: Template Match = "English | Math | Chymest"></p> <p><Xsl: choose></p> <p><XSL: WHEN TEST = "[Value () $ GT $ 85]"> Excellent </ XSL: WHEN></p> <p><XSL: WHEN TEST = "[Value () $ GT $ 70]"> General </ xsl: when></p> <p><XSL: WHEN TEST = ". [Value () $ GT $ 60]"> Sutra </ xsl: when></p> <p><XSL: OtherWise> Can't stand </ xsl: OtherWise></p> <p></ Xsl: choose></p> <p></ Xsl: template></p> <p></ Xsl: stylesheet></p> <p>Description:</p> <p>In <XSL: Choose> Select, start from the first <xsl: when>, test it one by one until a test condition is satisfied, the content is output, no longer testing the conditions behind; if you do not meet any of the conditions, Output content in <XSL: OtherWise>.</p> <p>Mark <XSL: WHEN> </ xsl: by> and <XSL: OtherWise> <XSL: if> or <xsl: choose>.</p> <p>Note: If you copy source code, remove the space</p> <p>Learn XSL (6) (return title)</p> <p>2000-05-08 · 禹 希 初 · CPCW</p> <p>Operators, relationships and logical operators, special characters, etc.</p> <p>Today we learn XSL's various operators to meet the requirements of the XSL style prepared to write greater flexibility.</p> <p>Table 1, operator and special characters</p> <p>Operator description</p> <p>/ Select child elements, return the direct child elements of the left element; if "/" is located at the left side to indicate the direct child elements of the root node</p> <p>// Remissive decline, regardless of the depth, search the specified element; if located on the left side indicates that the specified element is recursive from the root node</p> <p>Indicates the current element</p> <p>* Wildcard, choose any element, do not consider the name</p> <p>@ Get the property value, the prefix of the attribute name</p> <p>@ * Wildcard, select any properties, do not consider the name</p> <p>: Name scope separators, separated by the name of the name scope and the element or attribute name</p> <p>! * Apply a specified method on related nodes</p> <p>() * Packet, clearly specify priority</p> <p>Application filter style</p> <p>[] * Subscript operator, used to indicate elements in the collection</p> <p>Table 2, logical operator</p> <p>Compare operator Optional Description</p> <p>And $ or logic with or $ or || logic or</p> <p>NOT () $ not $ logic</p> <p>Table 3, relational operator</p> <p>= $ EQ $ equivalent</p> <p>= $ IEQ $ Equality (not case sensitive)</p> <p>! = $ NE $ 不</p> <p>$ INE $ 不 不 ((Not case sensitive)</p> <p><$ Lt $ less</p> <p>$ ILT $ less than (not case sensitive)</p> <p><= $ L $ less than is equal</p> <p>$ ILE $ less than or equal (not case sensitive)</p> <p>> $ GT $ greater than</p> <p>$ IGT $ greater (not case sensitive)</p> <p>> = $ GE $ greater than equals</p> <p>$ IGE $ greater than or equal (not case sensitive)</p> <p>$ all $ collecting operator, return "true" if all items in the collection meet the conditions</p> <p>$ any $ collection operator, return "true" if any project is met in the collection</p> <p>| Collection operator, return two sets of combination</p> <p>Example 1:</p> <p>Looking for a name with the "Web Development" skills from the personal resume and E-mail. Suppose the document structure is as follows:</p> <p><Document></p> <p><Resume></p> <p><Name> Name </ name></p> <p><SEX> SEX </ sex></p> <p><Birthday> birthday </ birthday></p> <p><Skill> Skill1 </ Skill></p> <p><Skill> Skill2 </ SkIll2></p> <p>...</p> <p><Skill> Skilln </ SKILL></p> <p></ Resume></p> <p><Resume></p> <p>...</p> <p></ Resume></p> <p>...</p> <p></ Document></p> <p>Find all the names of all those with "web development" skills from the above structure, the XSL document structure of E-mail is as follows:</p> <p><Table border = "1" cellspacing = "0"></p> <p><TH> Name </ TH> <TH> E-mail </ th></p> <p><Xsl: for-each select = "resume [$, $ SKILL = 'Web Development']>></p> <p><TR> <TD> <XSL: Value-of SELECT = "Name" /> </ td></p> <p><TD> <XSL: Value-of Select = "E-mail" /> </ td></p> <p></ TR></p> <p></ Xsl: for-energy></p> <p></ TABLE></p> <p>Description:</p> <p>1. [] ─── Expands the selection condition, only the personal resume satisfying the condition is displayed;</p> <p>2. $ any $ - Since everyone has a variety of skills, add $ any $ as a prefix so that all the skills of each person can be compared;</p> <p>3.SKILL = 'web development' - filter criteria</p> <p>Example 2</p> <p>Still the above XML document as an example, if you want to choose 1977/1/1, the name, skill and E-mail born before 1977/1/1, the corresponding XSL document structure is as follows (assuming birthday format YYYY / MM / DD):</p> <p><Table border = "1" cellspacing = "0"></p> <p><TH> Name </ TH> <TH> Skill </ TH> <TH> E-mail </ th> <xsl: for-each select = "resume [birthday $ lt $ '1977/1/1']" ></p> <p><Tr></p> <p><TD> <XSL: Value-of Select = "Name" /> </ td></p> <p><TD> <XSL: Value-of SELECT = "Skill [0]" /></p> <p><Xsl: for-each select = "Skill [index ()> 0]">,</p> <p><XSL: Value-of SELECT = "." /></p> <p></ Xsl: for-energy></p> <p></ Td></p> <p><TD> <XSL: Value-of Select = "E-mail" /> </ td></p> <p></ TR></p> <p></ Xsl: for-energy></p> <p></ TABLE></p> <p>Description:</p> <p>1. Birthday $ lt $ '1977/1/1' - Search Conditions, use "<" to be wrong here, so use "$ lt $" indicates less than.</p> <p>2. Skill [0] ─ ─ Represents the first item for Skill</p> <p>3. Skill [Index ()> 0] ─ Project indicating the second item (including second item) after Skill</p> <p>4. XSL: value-of select = "." ─ ─ Represents the value of the current tag</p> <p>I believe that everyone should notice that some functions appear in front and this example, such as index (), formatindex (), childnumber (), maybe everyone is not completely all of them? Please pay attention to the next lesson.</p> <p>Note: If you copy source code, remove the space</p> <p>Learn to XSL (7) (return heading)</p> <p>2000-05-09 · 禹 希 初 · CPCW</p> <p>XSL function</p> <p>Learn the XSL style method in this issue, you can use the XSL element <xsl: for-each>, <xsl: value-of>, <xsl: template>, <XSL: Apply-Templates> <XSL : If>, <xsl: when> TEST attributes are screened to the range of elements to provide greater flexibility.</p> <p>The XML is the same as DHTML (dynamic HTML), and these nodes are objects, and these objects are hierarchical, and the root node begins constitutes a hierarchical tree structure, which forms a document object model DOM. Through the properties of the object, the method reaches the purpose of the access control XML node.</p> <p>We don't intend to explain in detail one by one here, because this can be written into a more than one tutorial, we will discuss some common methods first, in order to have a general understanding of the object method of the DOM.</p> <p>Note: From this issue, all examples no longer provide complete source code. If you don't understand, please read the seven phases in front of the previous group and do it.</p> <p>First, End ()</p> <p>Meaning: Returns the last element in the collection.</p> <p>Example: Output last resume</p> <p>Assume that the XML file format is:</p> <p>... <resume> ... </ resume> ...... <resume> ... </ resume> ... The corresponding XSL file content is:</p> <p><Xsl: for-each select = "resume [end ()]"> ...... </ xsl: for-each></p> <p>or</p> <p><XSL: Templates Match = "Resume [end ()]> ...... </ xsl: templates></p> <p>or</p> <p><XSL: Apply-Template Select = "Resume [end ()]"> ...... </ xsl: Apply-Template></p> <p>Second, INDEX ()</p> <p>Meaning: Returns the position of the element in the collection, the return value is an integer, where the first element returns 0</p> <p>Example: Return to three resumes</p> <p>Resume [index () $ l $ 3]</p> <p>Note: Index () is related to the parent element, see the case:</p> <p><X></p> <p><Y /></p> <p><Y /></p> <p></ X></p> <p><X></p> <p><Y /></p> <p><Y /></p> <p></ X></p> <p>Returns the first <y> in <X></p> <p>X / y [index () = 0] or x / y [0]</p> <p>Third, Nodename ()</p> <p>Meaning: Returns the name of the element, ie the marking name</p> <p>Example: Select any elements, if its name (ie, the tagname) is equal to "name"</p> <p>* [nodename () = 'name'] or * [name]</p> <p>Fourth, Number ()</p> <p>Meaning: Convert value into numerical form, if not numerical, return empty, required parameters</p> <p>Example: Jeff Weiner (AGE), less than 30 years old resume (Resume)</p> <p>Resume [Number (AGE) $ LT $ 30] or Resume [AGE $ LT $ 30]</p> <p>Five, nodetype ()</p> <p>Meaning: Return the node type, resulting in a value. The following is a list of return values:</p> <p>Node type node type value node character form description</p> <p>ELEMENT 1 'Element'</p> <p>Element Attribute 2 'Attribute'</p> <p>Markup-Delimited Region of TEXT 3 'Text'</p> <p>Processing Instruction 7 'Processing_instruction'</p> <p>Comment 8 'Comment'</p> <p>Document Entity 9 'Document'</p> <p>Sixth, value ()</p> <p>Meaning: Returns the value of elements or attributes</p> <p>Example: Value () is the default method of the element or attribute, the following representation is equivalent</p> <p>Name! Value () = "name" with name = "name"</p> <p>@ attr = "attribute_value" with @ attr = "attribute_value"</p> <p>Note: @ is a property prefix, @ attr representation is attribute ATTR</p> <p>7. Attribute ()</p> <p>Meaning: Returns a collection of all attribute nodes, equivalent to "@ *"</p> <p>Example: Looking for all Resume elements, the value of at least one property is satisfied is "ABC"</p> <p>Resume [$ ATTRIBUTE () = 'ABC'] or Resume [$ ANY $ @ * = 'abc'] Find all Resume elements, meets at least one child element with attributes "ABC"</p> <p>Resume [$ any $ * / attribute () = 'abc'] or resume [$ no $ * / @ * = 'ABC']</p> <p>Eight, comment ()</p> <p>Meaning: Returns all comment nodes</p> <p>Example: for example</p> <p>Resume [$ comment () = '禹 初 初 初 初']]</p> <p>Represents looking for a comment statement</p> <p><! - 禹 初 初 初 初 -></p> <p>Elements <resume></p> <p>Nine, cdata ()</p> <p>Meaning: Returns a collection of nodes of all CDATA types</p> <p>Example: for example</p> <p>Resume [$ any $ cdata () = '禹 初 初 初 初 初']</p> <p>Indicates looking for the following statement (must be a direct sub-node)</p> <p><! [CDATA [初 初 初 初]]></p> <p>Elements <resume></p> <p>Ten, node ()</p> <p>Meaning: Returns a collection of all nodes other than root nodes and attribute nodes in the current context environment, equivalent</p> <p>"* | Pi () | comment () | text ()"</p> <p>Example: Looking for all Elements Resume, the name of its last node is "Skill"</p> <p>Resume [node () [end ()]! nodename () = 'skill']</p> <p>Find the first node of all resume elements: resume / node () [0]</p> <p>11. TextNode ()</p> <p>Meaning: Returns a collection of nodes of all text types</p> <p>Example: Find the second text node of each P element</p> <p>P / TextNode (1) or P! TextNode (1)</p> <p>Twelve, text ()</p> <p>Meaning: Returns all sets of nodes indicating the text string, equivalent to "cdata () | textNode ()";</p> <p>The content of this issue will be introduced, and another function date () has an error in my machine, making the browser automatically shut down, and a function PI () I have not found an appropriate application method, I don't introduce it. Using the script in XSL in the next period.</p> <p>Learn XSL (8) (return to the title)</p> <p>2000-05-10 · 禹 希 初 · CPCW</p> <p>Combination and application of scripts and XSL</p> <p>Sometimes, we may want the XML document to add some statistics or numbers, such as numbers, and use the previous knowledge. It is not easy to implement. Today will introduce two new elements <XSL: Eval> and <XSL: Script> so that we can easily handle this problem.</p> <p><Xsl: evAl></p> <p>meaning:</p> <p>Calculate script expressions, output a text string</p> <p>grammar:</p> <p><XSL: Eval Language = "Language-Name"></p> <p>Attributes:</p> <p>LANGUAGE - Specifies the name of the scripting language used, available attributes are "JavaScript", "JScript", "VBScript", "VBS", etc., default is "JScript".</p> <p><XSL: Script></p> <p>meaning:</p> <p>Disclaimer global variables or definition functions.</p> <p>grammar:</p> <p><Xsl: script language = "language-name"></p> <p>Attributes:</p> <p>With <XSL: EVAL></p> <p>Example:</p> <p>I don't know if you have an impression on the example of the fourth issue of "XML" with me "? The XML document does not have a resume number, but the output has a larger number of Rome digital serial numbers. Today, I will give a slightly complex example: If we write a year-end production statistics, there is a small meter, the routine method is to calculate it in advance, do not have to be, we can only give only single statistics, A small count is statistics when it is displayed. Please find out the fifth phase of "learning XML", the XML file does not have to be modified, the revised XSL file is as follows:</p> <p>......</p> <p><XSL: Template Match = "Document"></p> <p>......</p> <p><XSL: Apply-Templates SELECT = "Report" /></p> <p><TR> <TD> Small Meter </ TD></p> <p><TD> <XSL: Eval> Total (this, "q1") </ xsl: eval> </ td></p> <p><TD> <XSL: Eval> Total (this, "Q2") </ xsl: eval> </ td></p> <p><TD> <XSL: Eval> Total (this, "q3") </ xsl: eval> </ td></p> <p><TD> <XSL: Eval> Total (this, "Q4") </ xsl: eval> </ td></p> <p></ TR></p> <p></ TABLE></p> <p><XSL: Script></p> <p>Function Total (Node, Q) {</p> <p>TEMP = 0;</p> <p>Mark = '/ Document / Report /' q;</p> <p>v = node.selectnodes (mark);</p> <p>For (t = v.nextnode (); t; t = v.nextnode ()) {</p> <p>Temp = Number (T.Text);</p> <p>}</p> <p>Return Temp; // small value</p> <p>}</p> <p></ Xsl: script></p> <p></ Xsl: template></p> <p>Description:</p> <p>The black body part is added, pay attention to the addition of the part is divided into two parts, <XSL: Script> </ xsl: script> must be placed after </ table>, remember.</p> <p>SelectNodes () ─ is a method of XMLDomobject, returning all the collections of all the nodes satisfied in the document, the value and <xsl: for-each> and SELECT attributes use the same way, you can add filter, subscript, etc. Limit, such as:</p> <p>Looking for a quarter of a quarter of production greater than equal to 50</p> <p>/ Document / Report / Q1 [Value () $ GE $ 50]</p> <p>There is also a simpler way of writing above.</p> <p>// q1 [Value () $ GE $ 50]</p> <p>/ / Indicates that all nodes are traversed from the root node, find the node that satisfies the conditions, if there is a synonym with the same name but the meaning of the meaning, it is not recommended to use it. Taking this as an example, if you want to count the total output year, you can find a node (recommended to use the last one, this description will accurately find data required to summarize)</p> <p>// * [value () $ gt $ 0]</p> <p>or</p> <p>// (Q1 | Q2 | Q3 | Q4)</p> <p>or</p> <p>/ Document / Report / (Q1 | Q2 | Q3 | Q4)</p> <p>NextNode () - Returns the next node in the set point</p> <p>Number () - Converts the provided parameters to the value of the XSL function 2, for <XSL: Script> and <XSL: EVAL>, as well as the <XSL: if> and <xsl: When> EXPR properties. It is recommended that readers are familiar with at least one of JavaScript, JScript, VBScript, and if you can use XSL's work will be very limited. Due to the relationship, this is not described in detail.</p> <p>Note: If you copy source code, remove the space</p> <p>XLINK introduction</p> <p>2000-03-02 · Cai Yizi translation · Chinese XML</p> <p>If each of the data in each computer in this world can be identified, addressed, how exciting things will be! Xink is how to do this specification file on the network.</p> <p>HTML link</p> <p>Due to the popularity of WWW, most people are familiar with the basic concept of hyperbrapping, that is, "a link with two endpoints and one direction, two endpoints we are usually called Anchor. This link can be connected from one start point to any The target point of a network resource, these links may be a picture, a volume of the film, a sound, a program, an Element of HTML, or the elements, etc.</p> <p>If you often use a browser, you will know that when you press the right button on the junction, a menu will appear, and one of them is "On the new window".</p> <p>In HTML, it is made of these links with a "Anchor" flag.</p> <p>If you are a master writing HTML, you must know that there is a special sign in the Head sign called Link, which provides a variety of linkages: Compared to the way to link to the style sheet (new browser will provide more than one Select, let it choose which style sheet to use), or connect to a place with music (playback can be automatically played after downloading), or connect to another web page (allowing the browser to preload the page in advance, Take the time to wait for time), etc.</p> <p>The above described above is the function, in fact, there are many other hypertext linkages that have no way HTML, even if the hypercanic linking system provided by the early (late 1960-1970) HTML has no way. However, HTML will succeed because it uses the easiest way to use the ultra-connected knot, and the user does not have a special editor (editor) can make a web page.</p> <p>Multi-purpose link!</p> <p>Sometimes we see "link", we find that it looks not like a link, but in fact, why? Many things include electronic addresses, identification words, location, or queries, etc., all can have this action. When you think of the relationship between "Relationship", "ROLE", "Pointer" or "HAS A", there are "HAS A", or "HAS A", which can be labeled in XML (ExtensibleMarkUplanguage).</p> <p>Readers should have a concept. In HTML 4.0 specification, the defined hyperbraplencing standard is not all of the features, so we will make a clearer definition for connectivity:</p> <p>1. One connection can have one, two or even many ends, and each End can be an indicator, and the fact that the connection itself can be clearly specified as an external (External link, thus being connected to each end.</p> <p>2. A link does not have to have a direction, but it can also have a lot or no direction, in addition to this, the direction of the connection should not be from "context" to "part". 3. The connected end can be a range, not necessarily to connect to the entire resource or place.</p> <p>4. Connect the expression of the node is the role of the joint, "capturing" and "replacing" are only one of the possible behaviors. Therefore, the user setting is one of the performances of the connection between the user settings and replaces the screen.</p> <p>What is the use of XML link? In short, it can be used in the data type of data modeling, data exchange, hyperbraplen linking, or any different relationships.</p> <p>XLINKS has an important function to build "TopicMaps", which is a way to connect to various different network resources based on Metadata. TopicMaps allows different materials to have an external annotation. Therefore, we can say that TopicMaps are structural Metadata, which can be connected to different network resources based on all characteristic associated topics.</p> <p>XLINKS</p> <p>XLINK defines several commonly used linkages: Simple, Extended, Group, and Document.</p> <p>1. Simple usage is close to the usage of the HTML within the A logo (shown below the HTML writing).</p> <p>2.Extended usage contains elements of ARC and Locator and allows various types of expansion links.</p> <p>3. The usage of GROUP and Document is to link the group to some special files.</p> <p>We will explain the syntax of the Simple, there are two ways to know if a link is XLINK:</p> <p>1. Use simple words directly;</p> <p>2. Expressed in XLink: Type.</p> <p>Let's take a look at the example of simple below:</p> <p>1. Writing with HTML is as follows:</p> <p>2. Writing with XLINK:</p> <p>The same link, another XLINK can also be written:</p> <p>XMLns: XLINK Attribute is an example of a name domain (named), and the so-called name domain is convenient for users using several file type declaration (Document TypeDeclaration), as for such practices, we believe in the future In the HTML version, it will also work in this direction.</p> <p>Maybe we feel very strange, why will these ARCs will be connected together, but forming ExtendedLink? Some people may prefer (Figure 2), because this link does not "from" and "to", only HREF's address.</p> <p>Two originalities are included in the definition of Locator: HREF and ROLE. The HREF property contains the URL, and the Role property contains how to use the keywords.</p> <p>XLINK extends Uris used, where Actuate and Show are very important for XLINK, because of the following:</p> <p>1.Actuate's property can explain that Link is an Automatic or User-Command tracking.</p> <p>2. The attribute of SHOW means that the connection of the other end is to display a new window, or replace into the current window, or to analyze (if the link is coupled to the XML file).</p> <p>For HTML masters, the usage of the above HREF attribute is not usually because of the correct URL containing query conditions, and its main purpose is to query files.</p> <p>This URL uses a very special syntax, which is to ask questions (?) Before the URL is queried, and many of the links to the database use this skill. XPointer, which is developed in development, is a special query and a part of XLink. XPointer's grammar is? XPtr = plus XML PatHexpression [like ID (phone2)]. From the above example, the ID refers to the only identifier phone2. (This is the same as the usage of XLINK: ARC's from and To).</p> <p>XMLPATHEXPRESSION allows us to choose a special branch of ElementTreeOfstructure Data in different types.</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-90968.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="90968" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.065</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'Bkvy3_2F8SLzVWdv_2FA_2BL5jSa_2Fg8AZmqQMFC9SPbzsiVGQfDQHyf9azXbBb_2FIy0sZOLZIMuMmMhljFHWvjI'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>