240 likes | 357 Views
XML. A web enabled data description language 4/22/2001 By Mark Lawson & Edward Ryan L’Herault. XML HISTORY. Developed by work group, under authority of the W3C First seen in 1996, and standardized by the W3C in 1998 Simplified dialect of the SGML.
E N D
XML A web enabled data description language 4/22/2001 By Mark Lawson & Edward Ryan L’Herault
XML HISTORY • Developed by work group, under authority of the W3C • First seen in 1996, and standardized by the W3C in 1998 • Simplified dialect of the SGML
SGML "Standard Generalized Markup Language" • A method for creating interchangeable, structured documents • Standardized in 1986 (ISO8879:1986) • Can assemble a single document from many sources • Defines a document structure using a special grammar called a Document Type Definition • Adds markup to show the structural units in a document
HTML vs XML vs SGML • HTML is an SGML application (a DTD and set of processing conventions) • As such it’s much more limited than SGML and XML • It’s easy to learn • SGML is the mother of XML and HTML • It’s complicated – hundreds of pages in it’s definition • It has many extraneous features that aren’t needed on the web
HTML vs XML vs SGML II • XML is a subset of SGML • Valid SGML • Only uses the parts that are useful on the web • Requires more syntax checking than HTML • Is extendable like SGML • Has a small definition (25 pages) • Easy to learn
How do I execute or run an XML file? • You can't and you don't. • XML is not a programming language, so XML files don't ‘run’ or ‘execute’. • XML is a markup specification language and XML files are data.
Constructing your own XML You must supply a Document Type Definition What is a Document Type Definition (DTD)? • A context-free grammar like Extended BNF • Provides the rules that define the elements and structure of your new language • Thousands of SGML DTDs already in existence • SGML DTDs need to be converted to XML for use with XML systems
How is a DTD implemented? • A DTD is a file (or several files to be used together), written in XML's Declaration Syntax • It contains a formal description of a particular type of document • It sets out what names can be used for element types, where they may occur, and how they all fit together • Any browser (or application) with an XML parser could interpret an XML document instance by "learning" the rules defined by the DTD.
Defining the structure & Semantics of XML XML structure is defined in a schema • Defines shared markup vocabularies • Provide a means for defining the structure, content and semantics of XML • Introduces new levels of flexibility that may accelerate the adoption of XML for significant industrial use
Schemas • Schemas support inheritance and overriding old values • Schemas are not yet a formal Recommendation, but a number of sites are starting to serve useful applications as both DTDs and Schemas
An XML example • Example: Elements and Attributes This group of elements, attributes describe the contents of an address book. It includes a DTD which describes how all of the pieces work as XML. <?xml version=‘1.0’ ?> <!DOCTYPE address-book SYSTEM ‘address-book.dtd’> <!--loosely inspired by vCard 3.0 --> <address-book> <entry> <name> <fname>Jack</fname> <lname>Smith</lname> </name> <tel>513-555-3465</tel> <email href=‘mailto:jsmith@emailaholic.com’/> </entry> </address-book>
Required • The XML Declaration • <?xml version="1.0" standalone="no"?> • This is what tells an XML parser that the document is XML • XML Declaration w/ character set • <?xml version="1.0" encoding="ISO-8859-1"?>
Basic Syntax • All tags must be closed • The exception is an empty tag (i.e. <line-break/>) • All nested tags must close before the tag they are nested in • All attributes must have quotes • Case sensitive
Tags and DTD The DTD describes every object that can appear in the document An example section of a DTD is: <!ELEMENT address-book (entry+)> This is an entry that says the element <address-book> is composed of one or more <entry> elements.
Optional modifiers for the entries: • No modifier: Object appears once and only once in the element • +: Object appears at least once and can be repeated • *: Object appears zero or more times • ?: Object appears zero or one times
Elements composed of multiple entries An element can be composed of multiple entries, for example an entry in the address book has: a name, phone number, and email <!ELEMENT entry (name,tel*,fax*,email*)> Inside the parentheses are the elements that make up entry these can take the forms: • (e1 , e2): These elements will appear once each in order e1 e2 • (e1 | e2): One of these elements will appear (either or) • These can be combined as in: • (e1, (e2 | e3) )
Attributes of Elements Some elements have attributes, which are part of their data description. An attribute has: • The attribute tag opening: <!ATTLIST • The name of the element it belongs to: email • The attribute name: href • The attribute type: CDATA • Optionally a default value: #REQUIRED • The close bracket: >
Attributes of Elements II There can be more than one attribute listed in one attribute tag: <!ATTLIST email href CDATA #REQUIRED preferred (true |false) 'false'>
Referencing the DTD A DTD is referenced in the document using it with the tag: <!DOCTYPE address-book SYSTEM "address-book.dtd">
Referencing the DTD II The section of the tag:SYSTEM "address-book.dtd"> Can be replaced with or followed by a [ and the actual DTD as in: <!DOCTYPE name [ <!ELEMENT name (#PCDATA |fname |lname)*> <!ELEMENT fname (#PCDATA)> <!ELEMENT lname (#PCDATA)> ]>
Viewing the XML: XSL Because XML is just for describing data it isn’t inherently displayed in a particular way by a browser. XSL allows how things are displayed to be specified • XSLT transforms the data into new forms • XSLFO allows the style of the objects to be set • A similar thing to XLSO which is more supported is CSS
Uses of XML • intelligent agents - content personalization via smart pull/push (possibly with a date-stamped XML repository) • structured records (purchase order) object with methods and data (Java, and potentially JavaScript) • meta-content about your web site (improves searches) query results • graphical user interface of an application • persistent storage format (e.g. ODBMS-powered XML repository)
Uses of XML II • electronic service manuals • online process/procedures documentation • EDI (electronic data interchange) - mapping data between purchasing and inventory departments of same or different companies
References http://www.w3.org/XML/ http://www.ucc.ie/xml http://www.xml.com/ http://www.gca.org/whats_xml/whats_xml_xmlfiles.htm http://www.schema.net/ most informative site: http://wdvl.com/Authoring/Languages/XML/Intro/ Also: XML for Dummies XML by Example by Que