One of the advantages of XML technology is the selectivity of data output, that is, to select the required data output. The selection pattern statement:<xsl:for-each>, <xsl:value-of>, and <xsl:apply-template> that we talked about earlier simply select the nodes that arrive through the "/" symbol layer. If we do not need all of the XML data output, and only need to meet a certain condition of some of the data, "radish greens, to do everything", then conditional judgment <xsl:if> and multiple conditions of judgment <xsl:choose> and <xsl:when> To cater to this need, if you are familiar with the design, you will find them familiar.
If in XSL, first, introduce the syntax structure of the XSL element <xsl:if>:
expr── a script language expression that evaluates to True or false, and if the result is true, and the content is displayed in the output (this property can be omitted).
The script language type of the expression in the Language──expr property is the same as the value of the language property of the HTML tag script, which defaults to the "JScript" test── source data test condition.
Example:
This is in the case of a report named Report.xml, which reads as follows:
We use the XSL template in conjunction with the <xsl:if> we learned today, and write an XSL document for it, requiring a quarterly yield of less than or equal to 20 in red, the file name is report.xsl and the contents are as follows:
q1|q2|q3|q4── tags q1, q2, Q3, Q3 Use this template to determine the output
$le $── is "less than equal" in the relational operator, other relationships are less than ($LT $), greater than ($GT $), greater than or equal to ($ge $), equal to ($eq $), not equal to ($ne $), etc.
. That refers to the current tag
[]── represents a filter, only the tags that meet the filter criteria can be selected
Value () ──xsl function, other common XSL functions have text (), end (), index (), and so on.
In the next phase, we will learn about the other three elements of XSL that can be tested multiple times for the same data, producing the corresponding output according to different conditions.
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.