60 likes | 158 Views
CS144 Discussion - Saxon. Chu-Cheng Hsieh. Example: CS144.xml. <?xml version="1.0"?> <CS144> <TA>Chu-Cheng Hsieh</TA> <Student> <Name>Eric</Name> <Score>82</Score> </Student> <Student> <Name>Jay</Name> <Score>78</Score> </Student> <Student> <Name>Amy</Name>
E N D
CS144 Discussion - Saxon Chu-Cheng Hsieh
Example: CS144.xml <?xml version="1.0"?> <CS144> <TA>Chu-Cheng Hsieh</TA> <Student> <Name>Eric</Name> <Score>82</Score> </Student> <Student> <Name>Jay</Name> <Score>78</Score> </Student> <Student> <Name>Amy</Name> <Score>69</Score> </Student> <CS144>
Example: ToHtml1.xslt <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform” version="2.0" > <xsl:template match="/"> <html> <head> <title>Class information TA by <xsl:value-of select="/CS144/TA" /> </title> </head> <body> <h3>The TA of CS144 is <xsl:value-of select="/CS144/TA" /> .</h3> <br /> <table border="1"> <th> <td>Score</td> </th> <xsl:apply-templates select="/CS144/Student" /> </table> <br /> <h4>We have <xsl:value-of select="count(/CS144/Student)" /> students in total.</h4> </body> </html> </xsl:template> <xsl:template match="Student"> <tr> <td> <xsl:value-of select="Name" /> </td> <td> <xsl:value-of select="Score" /> </td> </tr> </xsl:template> </xsl:stylesheet>
Stud1.html <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Class information TA by Chu-Cheng Hsieh</title> </head> <body> <h3>The TA of CS144 is Chu-Cheng Hsieh .</h3><br><table border="1"> <th> <td>Score</td> </th> <tr> <td>Eric</td> <td>82</td> </tr> <tr> <td>Jay</td> <td>78</td> </tr> <tr> <td>Amy</td> <td>69</td> </tr> </table> <br><h4>We have 3 students in total.</h4> </body> </html>
ToHTML2.xslt <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform” version="2.0" > <xsl:template match="/"> <html> <head> <title>Class 144 is TA by <xsl:value-of select="/CS144/TA" /> </title> </head> <body> <h3>The TA of CS144 is <xsl:value-of select="/CS144/TA" /> . His email is <xsl:value-of select="/CS144/TA/@email" /> . </h3> <br /> <ol> <xsl:apply-templates select="/CS144/Student" /> </ol> <br/> <h4>We have <xsl:value-of select="count(/CS144/Student)" /> students in total.</h4> </body> </html> </xsl:template> <xsl:template match="Student"> <li> <ul> <li> Name: <xsl:value-of select="Name" /> </li> <li> Score:<xsl:value-of select="Score" /> </li> </ul> </li> </xsl:template> </xsl:stylesheet>
Stud2.html <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Class 144 is TA by Chu-Cheng Hsieh</title> </head> <body> <h3>The TA of CS144 is Chu-Cheng Hsieh . His email is cchucla@gmail.com . </h3><br><ol> <li> <ul> <li> Name: Eric</li> <li> Score:82</li> </ul> </li> <li> <ul> <li> Name: Jay</li> <li> Score:78</li> </ul> </li> <li> <ul> <li> Name: Amy</li> <li> Score:69</li> </ul> </li> </ol><br><h4>We have 3 students in total.</h4> </body> </html>