Internet Systems Design:
|
Example XML Code
1. XML Example<?xml version="1.0"?> <XML ID="XMLID"> <class> <student ID="0001"> <name>Jessica</name> <email>jessica@blue.weeg.uiowa.edu</email> </student> <student ID="0002"> <name>Peter</name> <email>peter@icaen.uiowa.edu</email> </student> <student ID="0003"> <name>Alen</name> <email>alen@yahoo.com</email> </student> </class> </XML> The result can be viewed at http://www.engineering.uiowa.edu/~ie181/XML/myxml.xml
2. CSS Exampleclass { display: block; border: 2px solid black; padding: 1em; background-color: #888833; color: #FFFFDD; font-family: Times, serif; font-style: italic; text-align: center; } student { display: block; border: 2px solid black; padding: 1em; background-color: #008833; color: #FFFFFF; font-family: Times, serif; font-style: italic; text-align: center; } name { display: block; border: 0px solid black; padding: 1em; background-color: #008833; color: #FFDDAA; font-family: Times, serif; font-style: italic; text-align: center; } email {display: block;} This CSS file can be viewed at www.engineering.uiowa.edu/~ie181/XML/mycssadv.css You can open it with notepad, another text editor or a CSS editor NOTE: In order to use this CSS file to present your XML data, you need to: In this case the XML file used is Example 1 above. The result can be viewed at: 3. XSL Example<?xml version="1.0" ?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"> <xsl:template match="/"> <HTML> <BODY> <TABLE BORDER="2"> <TR> <TD>Name</TD> <TD>E-mail Address</TD> </TR> <xsl:for-each select="XML/class/student"> <TR> <TD> <xsl:value-of select="name" /> </TD> <TD> <xsl:value-of select="email" /> </TD> </TR> </xsl:for-each> </TABLE> </BODY> </HTML> </xsl:template> </xsl:stylesheet> This file can be viewed at http://www.engineering.uiowa.edu/~ie181/XML/myxsl.xsl NOTE: In order to use this XSL file to present your XML data, you need to: The results can be viewed at:
http://www.engineering.uiowa.edu/~ie181/XML/myxmlxsl.xml 4. Use XSL to sort your XML dataModify the line of your XSL file: This XSL file can be viewed at http://www.engineering.uiowa.edu/~ie181/XML/myxslwithsort.xsl Change the XML file to reference this new XSL file. Load your XML file again to see what happens... The results can be viewed at: http://www.engineering.uiowa.edu/~ie181/XML/myxmlxslwithsort.xml |
|