and XML by bns26590


									             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


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

Web Server
Dynamic Web Pages

 Web Server
Basic PHP Template

<?php echo "Hello World"; ?>
PHP Variables

$txt="Hello World";
echo $txt;
PHP Conditionals

if ($d=="Fri")
echo "Have a nice weekend!";
echo "Have a nice day!";
PHP Functions

Similar to JavaScript functions, but more
 powerful. More than 700 unique
phpinfo( ) function - used for outputting
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" />
PHP Example

English Department reservation system
Built from open-source program called
 MRBS (Meeting Room Booking System)
2. XML overview

 XML is a metalanguage, i.e. a language that
  defines the rules and symbols of another
 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
XML Example
     <address type=“home”>
       <street>3938 Christytown Road</street>
       <city>Story City</city>
       <zip length=“9”>50248-1234</zip>
Uses of XML

 Provides a simpler method of structuring large
  data sets compared to earlier tagging systems like
 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
Impact of XML

 Provides greater flexibility in organizing
  information, but also introduces greater
 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”>
        <street>3938 Christytown Road</street>
        <city>Story City</city>
        <zip length=“9”>50248-1234</zip>
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.
  <!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


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%">
       <td colspan="2"><h1>Browse Record</h1></td>
       <td><b>Database Name: </b><xsl:value-of
 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
 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