260 likes | 339 Views
Learn about XML, its role in enterprise computing, document structure, relationships with HTML and SGML, popular applications, presentation methodologies, XML rules, DTD, and well-formed XML documents.
E N D
What is XML? • Stands for “Extensible Markup Language” • similar to SGML and HTML • document “tags” are used to define content not just formatting • can be defined for individual industries • Allows e-commerce applications to publish databases to Web more easily • merging of relational, O-O, and XML models
What is meant by a “document”? • A form of presentation • paper, browser screen, voice, etc. • Structure and organization of elements • memo, contract, recipe, etc. • Informational content • text and numbers organized in relation to each other
Relationship Among Markup Languages HTML SGML XML
What are some current XML applications? • On-line banking • Push technology • Web automation • Database Publishing • Software Distribution
Some sample HTML <!-- snippet of HTML --> <h1>Personal Computers For Sale</h1> <h2>Maker: Acme PC Inc.</h2> <h3>Model: Blaster 555</h3> <table border = 1> <tr> <td>Storage:</td> </tr> <tr> <td>RAM<td>72 MB</td> <tr> <td>Hard Disk</td><td>2 GB</td> </tr> </table>
XML Sample <!--Snippet of an XML Document --> <PcForSale> <Make>Acme PC Inc</Maker> <Model>Blaster 555</Model> <Storage> <Ram Units = “MB”>72</Ram> <HardDisk Unites = “GB”>2</HardDisk> </Storage> </PcForSale>
How is XML Presented? • XML includes a DTD (Document Type Definitions) • lists the element types and the order you are allowing them to occur • XML parser tests to see them are valid DTDs • XSL (XML Style Language) • similar to cascading style sheets • contain presentation information
Another Example • Convert a business card into an XML document • start with representative XML content • define DTD elements
XML Rules • Open and close tags define “elements” and each element must have a closing tag (except for “empty” elements) • Elements appear in a strict hierarchy; upper elements are parents of lower “child” elements. • DTD is not mandatory but it ensures two parties define a docement’s contents the same. • DTDs constrain the data, the hierarchy of content, and the number of times it may appear
XML Rules (cont.) • Elements • XML is case sensitive • must have 1 and only 1 “root” element • elements consist of an “element name” and “element content” • element content may consist of character or other data or even other elements embedded • an XML schema or “tree” describes hierarchy of elements • empty elements are indicated by a trailing backslash
Well-Formed XML Documents • Have one root element • All non-empty elements have start and stop tags that match exactly • All empty elements have correct trailing slash • Elements are strictly nested with no overlapping elements
Attributes • Allow designer to add richer metadata to elements • Consist of attribute name and attribute value • attribute values are bounded by quotes • can specify as many attributes for each element as you want • some authors use UC text for attribute names to easily distinguish <addresses> <address ADDTYPE=“shipto” <firstname>Robert</firstname> ……… </address> </addresses>
Defining a DTD • Element declaration begins with “<!ELEMENT” and ends with > • this contains an element name and content model surrounded by parentheses • elements can contain data or other elements or be empty • to indicate it contains data we use (#PCDATA) • if it contains other elements we list them in brackets (name, title, address, etc) • empty elements use the key word “EMPTY”
Further DTD Specifications • Designer can specify the number of times an element may appear • “?” means it may occur 0 or 1 times in document • “*” means it may occur 0 or more times • “+” means it may appear 1 or more times • can enumerate possible alternative with “|” • can specify an attribute is required with #REQUIRED • #IMPLIED means attribute may not have a value
Try another example • Think of your resume, posted say on Monster.com • What does html for this look like? • Write your resume in XML???? • What is the “root” element? • Why would this be valuable?
Another Example • Creating an “order” in XML • include a “prolog”of XML document • header information before root element • may include processing instructions and DTD declaration ex. <?xml version=“1.0”?> <!DOCTYPE order SYSTEM “order.dtd”> • may include comments in prolog or after • start with <!- and end with ->
XML Document XML App XML Processor XML DTD
Some XML Processors • Processors are either “validating” or “non-validating” • Msxml • developed by MS Corp. Java and ActiveX versions • Aelfred • Java-based XML. Microstar Corp. • XP • Java-based XML processor by James Clark