This document demonstrates the usage of XSL: For-each value-.
The learning of XSL is messy, so the documents are also messy. Most of the main things are in program comments. Take a look ......
Let's take an example: temp. xml
<? XML version = "1.0" encoding = "gb2312"?> <! -- Declaration -->
<? XML-stylesheet type = "text/XSL" href = "test. XSL"?> <! -- Pi -->
<! -- Note that each XML file must have a root element. Document in this file cannot be removed. Otherwise, the two resume files are tied together without the root element. -->
<Document>
<Resume>
<Name> high </Name>
<Age> 23 </age>
</Resume>
<Resume>
<Name> AGAO </Name>
<Age> 23 </age>
</Resume>
</Document>
The following is the test. XSL file.
<? XML version = "1.0" encoding = "gb2312"?>
<XSL: stylesheet xmlns: XSL = "http://www.w3.org/TR/WD-xsl"> <! -- All content is case sensitive -->
<! -- XSL: stylesheet is used for the same purpose as XSL: Transform. It seems that the root element must be defined using XSL: template match. See the following annotations without stylesheet. -->
<XSL: template match = "/">
<Body> <XSL: For-each select = "document/resume"> <! -- Actual relative path/document/resume -->
<XSL: value-of select = "name"/> <! -- Note that the actual path of name here is/document/resume -->
<XSL: value-of select = "Age"> </XSL: value-of> <br/>
</XSL: For-each>
</Body>
</XSL: Template>
</XSL: stylesheet>
<! -- Examples without stylesheet
<XSL xmlns: XSL = "http://www.w3.org/TR/WD-xsl">
<Body>
<XSL: For-each select = "/document/resume"> no match = "/" must be used here/document/resum
<XSL: value-of select = "name"/>
<XSL: value-of select = "Age"> </XSL: value-of> <br/>
</XSL: For-each>
</Body>
</XSL>
-->