Follow me. The operator of an XSL (6) XSL

Source: Internet
Author: User
Tags filter logical operators mail xsl
Table one, operators, and special characters
Operator Describe

/

Selects the child element, returns the immediate child element of the left element, and if "/" is at the leftmost point, the direct child element that selects the root node

//

Recursive descent, regardless of depth, searches for the specified element; If the leftmost representation is from the root node recursive descent search for the specified element

.

Represents the current element

*

wildcard character, select any element, regardless of name

@

Gets the property value as a prefix to the property name

@*

wildcard character, select any property, regardless of name

:

The name scope delimiter, separating the name scope prefix from the element or attribute name

!*

Apply the specified method on the related node

()*

Group, explicitly specifying the order of precedence

[]

Apply Filter Style

[]*

Subscript operator, used to indicate elements in the collection

Table II, logical operators

Optional Way Describe

and $and $ or &&

Logic and

or $or $ or | |

Logical OR

Not () $not $

Logical non

Table III, relational operators

Optional Way Describe

= or $eq $

Equal

= or $ieq $

Equality (case-insensitive)

!= or $ne $

Range

$ine $

Unequal (case-insensitive)

< or $LT $

Less than

$ilt $

Less than (case-insensitive)

<= or $le $

Less than or equal to

$ile $

Less than or equal (case-insensitive)

> or $GT $

Greater than

$igt $

is greater than (case-insensitive)

>= or $ge $

Greater than or equal to

$ige $

Greater than or equal (case-insensitive)

$all $

Collection operator, returning true if all items in the collection meet the criteria

$any $

Collection operator, returning true if any item in the collection satisfies the condition

|

Collection operator, which returns a union of two sets

Example one:

Look for the name and e-mail from your resume for people with "web development" skills. Suppose the document structure looks like this:

<document>
<resume>
<name>name</name>
<sex>sex</sex>
<birthday>birthday</birthday>
<skill>skill1</skill>
<skill>skill2</skill2>
...
<skill>skilln</skill>
</resume>
<resume>
...
</resume>
...
</document>

The XSL document structure for the names and e-mail of all the people who have web development skills is found in the above-structured personal resume as follows:

<table border= "1" cellspacing= "0" >
<TH> name </TH><TH>E-Mail</TH>
<xsl:for-each select= "Resume [$any $skill=" web Development "]" >
<tr><td><xsl:value-of select= "Name"/></td>
<td><xsl:value-of select= "e-mail"/></td>
</TR>
</xsl:for-each>
</TABLE>

Description

1.[]── Indicates the selection condition, only the resume that satisfies the condition is displayed.

2. $any $── Because each person has a variety of skills, so add $any$ as a prefix so that everyone's skills can be compared.

3.skill= ' web Development '--filter criteria.

Example Two,

Still, for example, the XML document above, if you want to select the name, skills, and e-mail of the person born before 1977/1/1, the corresponding XSL document structure is as follows (assuming the birthday format is YYYY/MM/DD):

<table border= "1" cellspacing= "0" >
<TH> Name </TH><TH> Skills </TH><TH>E-Mail</TH>
<xsl:for-each select= "resume[birthday$lt$" 1977/1/1 "]" >
<TR>
<td><xsl:value-of select= "Name"/></td>
<TD>
<xsl:value-of select= "skill[0]"/>
<xsl:for-each select= "Skill[index () >0]" >,
<xsl:value-of select= "." />
</xsl:for-each>
</TD>
<td><xsl:value-of select= "e-mail"/></td>
</TR>
</xsl:for-each>
</TABLE>

Description

1.birthday $lt $ ' 1977/1/1 '-search conditions where "<" is an error, using "$lt $" to represent less than.

2.skill [0]── represents the first item to select Skill.

3.skill [Index () >0]── represents items that have been selected after the second item of skill (including the second item).

4.xsl:value-of select= "."--to select the value of the current tag.

I believe you should note that some functions, such as index (), Formatindex (), and Childnumber (), may not be fully understood in the preceding and present examples. Please pay attention to the next lesson.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.