XSL can be used to completely separate the data from the format, and the following compares the difference between a xml+css and a xml+xsl.
XML + CSS
The contents of the Resume.xml file are as follows:
1 <?XML version= "1.0" encoding= "GB2312"?>2 <?xml-stylesheet type= "text/css" href= "Resume.css "?> 3 <Resume> 4 <name>Euchierne</name> 5 <Sex>Man</Sex> 6 <Birthday>1977.5</Birthday> 7 <Skill>Database design and maintenance, web development</Skill> 8 </Resume>
The contents of the Resume.css file are as follows:
1 resume{Display:block;} 2 name{display:block; font-size:120%;} 3 sex{display:block; text-indent:2em} 4 birthday{display:block; text-indent:2em} 5 skill{display:block; Text-indent:2em}
Effect:
XML + XSL
The contents of the Resume.xml file are as follows:
1 <?XML version= "1.0" encoding= "GB2312"?>2 <?xml-stylesheet type= "text/xsl" href= "resume.xsl "?> 3 <Resume> 4 <name>Euchierne</name> 5 <Sex>Man</Sex> 6 <Birthday>1977.5</Birthday> 7 <Skill>Database design and maintenance, web development</Skill> 8 </Resume>
The contents of the Resume.xsl file are as follows:
1 <?XML version= "1.0" encoding= "GB2312"?>2 <Xsl:stylesheetversion= "1.0"xmlns:xsl= "Http://www.w3.org/1999/XSL/Transform">3 <xsl:templateMatch="/">4 <HTML>5 <Head> 6 <title>Personal Resume</title> 7 </Head><Body> 8 <Xsl:for-eachSelect= "Resume"> 9 <P/> Ten <TableBorder= "1"cellspacing= "0"> One <captionstyle= "font-size:150%; font-weight:bold"> A Personal Resume - </caption> - <TR> the <th>Name</th><TD><xsl:value-ofSelect= "Name"/></TD> - <th>Gender</th><TD><xsl:value-ofSelect= "Sex"/></TD> - <th>Birthday</th><TD><xsl:value-ofSelect= "Birthday"/></TD> - </TR> + <TR> - <th>Skills</th><TDcolspan= "5"><xsl:value-ofSelect= "Skill"/></TD> + </TR> A </Table> at </Xsl:for-each> - </Body> - </HTML> - </xsl:template> - </Xsl:stylesheet>
Effect:
Reference:
http://justcoding.iteye.com/blog/778361
Http://www.w3school.com.cn/xsl/xsl_for_each.asp
XSL Simple instance