xml a web enabled data description language 4/22/2001 by mark lawson & edward ryan l’herault
TRANSCRIPT
XMLXML
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 How do I execute or run an XML file?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 XMLConstructing 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?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 & Defining the structure & Semantics of XMLSemantics 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 exampleAn 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:[email protected]’/>
</entry></address-book>
RequiredRequired
1. The XML Declaration• <?xml version="1.0"
standalone="no"?>• This is what tells an XML parser that
the document is XML
2. 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 DTDTags 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:
1. No modifier: Object appears once and only once in the element
2. +: Object appears at least once and can be repeated
3. *: Object appears zero or more times
4. ?: Object appears zero or one times
Elements composed of Elements composed of multiple entriesmultiple 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 ElementsAttributes 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 IIAttributes 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 DTDReferencing the DTD
A DTD is referenced in the document using it with the tag:
<!DOCTYPE address-book SYSTEM "address-book.dtd">
Referencing the DTD IIReferencing 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: XSLViewing 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 XMLUses of XML
1. intelligent agents - content personalization via smart pull/push (possibly with a date-stamped XML repository)
2. structured records (purchase order) object with methods and data (Java, and potentially JavaScript)
3. meta-content about your web site (improves searches) query results
4. graphical user interface of an application 5. persistent storage format (e.g. ODBMS-
powered XML repository)
Uses of XML IIUses of XML II
6. electronic service manuals7. online process/procedures
documentation 8. EDI (electronic data interchange) -
mapping data between purchasing and inventory departments of same or different companies
ReferencesReferences
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 DummiesXML by Example by Que