XSL Simple instance

Source: Internet
Author: User
Tags xsl xsl file

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

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.