Jump to content

Web technologies -- Laboratory 4 -- 2007-2008 -- info.uvt.ro

From Wikiversity
Important! These pages are somehow outdated and it is recommended to consult the newer version at Web technologies -- 2009-2010 -- info.uvt.ro (by Marc Frâncu).
[edit]


XML

[edit]

References

[edit]


Discussion points

[edit]
  • data description language
  • validity, DTDs and schemas [1]
  • usages [2]
  • syntax [3]
    • XML declaration
    • root element
    • elements [5]
      • element name
        • case sensitive
        • namespaces [6]
      • start tags, end tags
      • attributes [7]
      • proper nesting
    • character entities, CDATA [8]
    • comments


Example

[edit]
 <?xml version="1.0" encoding="ISO-8859-1"?>
 <?xml-stylesheet type="text/xsl" href="queue.xsl"?>
 
 <queue>
     <link>
         <name>Paul Graham -- The Roots of Lisp</name>
         <uri>http://www.paulgraham.com/rootsoflisp.html</uri>
     </link>
     <link>
         <name>LL1: Lightweight Languages Workshop</name>
         <uri>http://ll1.ai.mit.edu/</uri>
     </link>
     <link>
         <name>The Java Language Environment</name>
         <uri>http://java.sun.com/docs/white/langenv/</uri>
     </link>
     <link>
         <name>The Evolution of Lisp</name>
         <uri>http://citeseer.ist.psu.edu/steele93evolution.html</uri>
     </link>
     <link>
         <name>Delimited continuations in operating systems</name>
         <uri>http://okmij.org/ftp/papers/context-OS.pdf</uri>
     </link>
     <link>
         <name>Pascal Costanza's Highly Opinionated Guide to Lisp</name>
         <uri>http://p-cos.net/lisp/guide.html</uri>
     </link>
 <!--
     <link>
         <name></name>
         <uri></uri>
     </link>
 -->
 </queue>


XSL

[edit]

References

[edit]


XSLT

[edit]

References

[edit]


Discussion points

[edit]
  • data transformation language
  • elements [9]
  • functions [15]


Example

[edit]
 <?xml version="1.0" encoding="ISO-8859-1"?>
 
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     
     <xsl:template match="/queue">
         <html>
             <head>
                 <title>Reading queue</title>
             </head>
             <body>
                 <ul>
                     <xsl:for-each select="./link">
                         <li>
                             <strong><xsl:value-of select="./name" /></strong>
                             <a>
                                 <xsl:attribute name="href">
                                     <xsl:value-of select="./uri" />
                                 </xsl:attribute>
                                 <xsl:value-of select="./uri" />
                             </a>
                         </li>
                     </xsl:for-each>
                 </ul>
             </body>
         </html>
     </xsl:template>
 
 </xsl:stylesheet>


Assignment

[edit]

First step: Create a database like XML (like the one in the example from above) file with:

  • at least 10 record like elements (for example the link element);
  • each record should have at least 4 attribute like elements (for example the name or uri element);
  • each record should have at least 3 sub-records (for example I could extend the link elements to also contain multiple comment elements);


Second step: Create an XSLT file -- that is used by your XML file -- to transform the database into a HTML file. Each information available in the XML file should be presented in the generated HTML.


As usually the assignments should be commited using SVN in the folder <user-name>/assignment-03 in one of the repositories:



Ciprian Dorin Craciun, 2007-10-24, ccraciun@info.uvt.ro