and XML by bns26590

VIEWS: 48 PAGES: 30

									             and XML
A primer for Web design students


          Lee Honeycutt
           English 313
Why PHP and XML?

 Aren’t these just passing fad buzzwords to
  make cyber-snobbish people sound
  intelligently superior at cocktail parties?
 Can’t I just develop all my information in
  HTML and leave it at that?
 If I’m already using HTML on IIS on .NET, why
  would I want to use PHP and MySQL or XML
  with XSLT to generate XHTML and XSL-FO to
  generate PDFs?
Acronymophobia (ăk'rə-nĭmă'fōbē-ə) n.

  Disoriented paranoid state of mind
  caused by excessive exposure to an
  overwhelming number of technology
  acronyms and buzzwords. Easily cured
  by this presentation.
Today, we’ll cover…

1.   PHP and MySQL for dynamic web pages
2.   XML Overview
3.   XML terms and processes
4.   XML transformations
5.   XML software
6.   Impact of XML
1. What is PHP?

Originally “Personal Home Page,” a
 variant of Perl scripting language.
Open-source language for server-side
 scripting applications.
Works with variety of relational
 databases to create dynamic web sites
 on just about any server platform.
   Static Web Pages

                           index.html




             résumé.html   writing.html   presentations.html




Web Server
Dynamic Web Pages
              index.php




 Web Server
Basic PHP Template

<html>
<body>
<?php echo "Hello World"; ?>
</body>
</html>
PHP Variables

<?php
$txt="Hello World";
echo $txt;
?>
PHP Conditionals

<?php
$d=date("D");
if ($d=="Fri")
echo "Have a nice weekend!";
else
echo "Have a nice day!";
?>
PHP Functions

Similar to JavaScript functions, but more
 powerful. More than 700 unique
 functions.
phpinfo( ) function - used for outputting
 information
phpforms ( ) function - inputting
 information to database
PHP Form Function
<form action="welcome.php” method="POST">
Enter your name: <input type="text" name="name" />
Enter your age: <input type="text" name="age" />
<input type="submit" />
</form>
PHP Example

English Department reservation system
Built from open-source program called
 MRBS (Meeting Room Booking System)
http://reserve.engl.iastate.edu/
2. XML overview

 XML is a metalanguage, i.e. a language that
  defines the rules and symbols of another
  language.
 XML is not used on the web, but instead used
  to define other markup languages, such as
  XHTML, the replacement of HTML.
 Allows us to define markup languages
  customized to our individual needs instead of
  relying on pre-existing tags.
Think of XML as….

 An indented outline of a very large document.
 A database table expressed via element tags
  within one big flattened text file.
 A family of technologies that work in tandem to
  express information in a variety of ways.
 The Rosetta Stone of the information age,
  allowing you to move information from one
  context to another through a standardized
  structure.
XML Example
     <address type=“home”>
       <name>
          <first>Lee</first>
          <last>Honeycutt</last>
       </name>
       <street>3938 Christytown Road</street>
       <city>Story City</city>
       <state>Iowa</state>
       <zip length=“9”>50248-1234</zip>
     </address>
Uses of XML

 Provides a simpler method of structuring large
  data sets compared to earlier tagging systems like
  SGML.
 Publishes information to various media formats
  from a single source.
 Serves as a platform-independent lingua franca
  for sharing hierarchically structured information
  between various programs.
 Embeds links in RSS feeds for news and
  weblogs.
Impact of XML

 Provides greater flexibility in organizing
  information, but also introduces greater
  complexity.
 Requires greater upfront planning and design
  of information sets and their rhetorical use.
 Separates content from style, which has huge
  rhetorical implications.
3. Key XML Terms & Processes

 Elements - similar to HTML <tags>, but defined
  by the user instead. They describe, in human
  language, the data they surround.
 Attributes - name and value pairs used to
  distinguish unique instances of an element.
 Entities - shorthand placeholders for information
  used often within a document
 DTDs & Schemas - declared dictionaries of
  elements that model a document’s content.
XML Example
     <address type=“home”>
        <name>
            <first>Lee</first>
            <last>Honeycutt</last>
        </name>
        <street>3938 Christytown Road</street>
        <city>Story City</city>
        <state>Iowa</state>
        <zip length=“9”>50248-1234</zip>
     </address>
Purpose of DTDs & Schemas

 Define the set of allowed tags and attributes in
  the document.
 Describe a document’s content model using
  rules by which tags and data are ordered.
 Provide easy model management through
  references to shortcuts and external files.
Anatomy of a DTD

 Entity - shorthand name/value pairs that
  make XML docs easier to write and parse.
  Similar to a Word macro.
  EX: <!ENTITY isu “Iowa State University”>
 Elements - define actual markup tags.
  EX:
  <!ELEMENT name (first, middle?, last)>
  <!ELEMENT street (#PCDATA)>
  <!ELEMENT city (#PCDATA)>
Entity placed in a document

<!ENTITY isu “Iowa State University”>
<description>Though its claim to the first
 digital computer is debatable, &isu; does
 have the world’s only six-sided virtual
 reality facility.</description>
When XML is parsed, &isu; expands to
 “Iowa State University”
4. Transforming XML

 XSL (Extensible Stylesheet Language) -
  special type of XML document that transforms
  XML data into styled format. Similar to HTML’s
  Cascading Stylesheets.
 XSLT (Transformations) - usually used for
  transformation to XHTML.
 XSL-FO (Formatting Objects) - used for
  page formats such as PDF and MS Word.
XML Transformations
            XSLT      XHTML

 DTD

 XML
           XSL-FO
XSLT stylesheets…

 …contain two types of elements:
Instructions - describe how nodes of
 the XML document will be transformed.
Literals - output text, such as XHTML
 tags, that appear exactly as they appear
 in the stylesheet. Act as a template for
 XML content.
Instructions & Literals
<table width="100%">
   <tr>
       <td colspan="2"><h1>Browse Record</h1></td>
   </tr>
   <tr>
       <td><b>Database Name: </b><xsl:value-of
            select="fmrs:datasource/@database"/></td>
   </tr>
</table>
XPath
 XPath - syntax for describing how nodes of an XML
  document are processed.
 <xsl:apply-templates select=“expression”>
 <xsl:for-each select= “expression”>
 Conditionals
    <xsl:if test=“expression”>
    <xsl:choose>
         <xsl:when>
         <xsl:otherwise>
 <xsl:sort selection=“expression”>
5. XML Software

 Some applications are moving to XML as their
  foundation. EX: OpenOffice.
 Most database programs have an XML export
  feature.
 XML editors and companion components:
   Cross Platform - Editix, oXygen, Exchanger
   Windows - XML Spy, XMetal, and Stylus
6. Impact of XML
 Provides greater flexibility in organizing information,
  but also introduces greater complexity.
 Requires greater upfront planning and design of
  information sets and their rhetorical use.
 Separates content from style, which has huge
  rhetorical implications, just as does the use of CSS.

								
To top