WebBased XML File Repository CS 360 Project 3
Web-Based XML File Repository CS 360 Project #3 2002. 5. 21 Dongjoon Hyun 1
Contents • Web-Based XML File Repository – Functions • XML – DTD – XSL • CGI / HTML Seeing is believing. http: //eve. kaist. ac. kr/~cs 360/ 2
Web-Based XML File Repository • Web-Based – Browser • XML File Repository – HTTP Server – Manage User File Directory (XML, XSL, …) XML File XSL File 3
Web-Based XML File Repository Functions Create Empty File View File Name List View File Content Edit/Save File Content Remove File Upload File 4
XML(e. Xtensible Markup Language) • A Language – designed to describe content, rather than presentation – consists of elements • element = start tag + content + end tag Start Tag <person> <name> Alan </name> <age> 42 </age> <email> agb@abc. com </email> </person> • start tag may have attributes End Tag Attribute <product> <name language=“French”>trompette six trous</name> <price currency=“Euro”> 420. 12 </price> </product> 5
DTD(Document Type Definition) • Describe the structure of XML Root element Any number of person element - e+: one or more <!DOCTYPE db [ - e? : zero or one <!ELEMENT db (person*)> <!ELEMENT person (name, age, email)> - e|e’: alternation - e, e’: concatenation <!ELEMENT name (#PCDATA)> ]> <!ELEMENT age (#PCDATA)> <!ELEMENT email (#PCDATA)> db. dtd Person’s subelements Name, age, email (ordered!!) Character data 6
sample. xml <? xml version=“ 1. 0” encoding=“EUC-KR”? > <? DOCTYPE person SYSTEM “db. dtd”? > <db> <person> <name> Alan </name> <age> 42 </age> <email> agb@abc. com </email> </person> <name> Alan 2 </name> <age> 43 </age> <email> agc@abc. com </email> </person> </db> 7
XSL(XML Stylesheet Language) • XSL – a stylesheet language designed to be used with XML data and documents – transform XML into another Format • XSL is a set of template rules • How does XSL work? * Output : raw text (Mainly, HTML. . ) 8
<? xml version="1. 0" encoding="EUC-KR"? > <xsl: stylesheet xmlns: xsl="http: //www. w 3. org/TR/WD-xsl"> <? xml version="1. 0" encoding="EUC-KR"? > <? xml: stylesheet type="text/xsl" href=“memo. xsl"? > <xsl: template match="/"> <xsl: apply-templates /> </xsl: template> <memo> <title> 조교 강의. </title> <time> 저녁 8시, 오후 3시. </time> </memo> <xsl: template match="memo"> <HTML> <HEAD> <TITLE> 메모 </TITLE> </HEAD> <BODY> <xsl: apply-templates /> </BODY> </HTML> </xsl: template> <xsl: template match=“title"> <B> <xsl: value-of /> </B> </xsl: template> <xsl: template match=“time"> <I> <xsl: value-of /> </I> </xsl: template> </xsl: stylesheet> memo. xsl memo. xml <HTML> <HEAD> <TITLE> 메모 </TITLE> </HEAD> <BODY> <B> 조교 강의. </B> <I> 저녁 8시, 오후 3시. </I> </BODY> </HTML> 9
CGI (Common Gateway Interface) • A standard for running external programs from a World-Wide Web HTTP server. – specifies how to pass arguments to the executing program as part of the HTTP request. – defines a set of environment variables. Commonly, the program will generate some HTML which will be passed back to the. Request Web Browser HTTP Server Executable File? (. cgi ) Static File? Execution Result Execute Program 10
CGI Program Call • Program Call – http: //eve. kaist. ac. kr/~cs 360/project 3. cgi • Arguments Passing – http: //eve. kaist. ac. kr/~cs 360/project 3. cgi? help => project 3. cgi help – http: //eve. kaist. ac. kr/~cs 360/project 3. cgi? list => project 3. cgi list – http: //eve. kaist. ac. kr/~cs 360/project 3. cgi? create+test. xml => project 3. cgi create test. xml 11
CGI Program Example … cout<< "Content-Type: text/htmlnn" << "<HTML>n" << "<BODY>n" << "<TABLE BGCOLOR="#DCDCDC" BORDER=1>n" << "<TR><TH COLSPAN=2 BGCOLOR="#999999">Sample CGI v 1. 0 Commands</TH></TR>n" << "<TR><TD>list</TD><TD>print filename list </TD></TR>n" << "<TR><TD>create</TD><TD>create file</TD></TR>n" << "<TR><TD>remove</TD><TD>remove file</TD></TR>n" << "<TR><TD>edit</TD><TD>display editable form of file contents</TD></TR>n" << "<TR><TD>save</TD><TD>save the modified file contents</TD></TR>n" << "<TR><TD>upload</TD><TD>upload file</TD></TR>n" << "</TABLE>n" << "</BODY>n" << "</HTML>n" << endl; … 12
HTML ‘Form’ Tag <HTML> <BODY> <FORM name=“form 1” action=“test. pl” method=“get”> <INPUT type=“text” maxlength=“ 20” name=input 1 size=“ 20”> <INPUT type=“submit” value=“SUBMIT”> </FORM> </BODY> </HTML> http: //organ/~hyundong/test. pl? input 1=test 1&input 2=t 2 char str[100]; char* str. Ptr; str. Ptr = getenv("QUERY_STRING"); strcpy(str, str. Ptr); printf(“<B>%s</B>", str); 13
Reference • http: //www. w 3. org/TR/REC-xml • http: //www. w 3. org/TR/XSLT 14
- Slides: 14