4. we have mentioned the XPath syntax. XPath is a language used to help XSLT search for location information in the XML source document. In actual application process, XPath and XSLT are always used together. in the syntax example in the previous chapter, we have applied the 4. XPath syntax.
As we have mentioned earlier, XPath is a language used to help XSLT search for location information in XML source documents. In actual application, XPath and XSLT are always used together. in the syntax example in the previous chapter, we have applied the XPath syntax, but we didn't understand it. However, W3C divides them into two scales, so we also split them into two chapters to explain them.
4. XPath syntax
4.1 Current position
4.2 Addressing control
4.3 operator
4.4 function
4.1 Current position
When we use XSLT to process XML source documents, we use Context to present the node status currently being processed by templates. For example, in the xsl: template match = '/' statement, Context is displayed on the root node of the document. I don't know how to accurately translate the term Context. it is similar to a pointer in C language, showing the current running status of the program. Understanding Context is very important for accurate processing of XSL templates. when the document output by your XSL template is different from what you want, the first thing to analyze is where Context is.
Location Paths is used to set the status of the Context node you want to find. It is similar to the DOS directory command. Let's look at an example.
Child: PEOPLE/descendant: PERSON is the XPath syntax, and this expression is a Location Paths. the code clarifies that the child elements of all PEOPLE elements and the child elements of all PERSON elements should be displayed. We usually adopt a simpler syntax:
We will illustrate two ways of expressing path: '/' and '//'.
'/' Is the node that represents the current document, similar to the DOS directory delimiter. For example,/PEOPLE indicates that the PEOPLE element under the root node is selected; PEOPLE/PERSON indicates that all the PESON sub-elements under the PEOPLE element are selected.
'//' Indicates all nodes in the current document. Similar to viewing all directories. For example, // PEOPLE indicates that all PEOPLE elements in the document are selected, regardless of their hierarchy. PEOPLE // PERSON indicates all the PERSON elements under the PEOPLE element, regardless of their hierarchy.
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