The Official 2002 XML Marathon April 4, 2002. Revised Requirements A photocopy of the original text A short description (read: single paragraph) discussing.

Slides:



Advertisements
Similar presentations
Defining XML The Document Type Definition. Document Type Definition text syntax for defining –elements of XML –attributes (and possibly default values)
Advertisements

XML 6.3 DTD 6. XML and DTDs A DTD (Document Type Definition) describes the structure of one or more XML documents. Specifically, a DTD describes:  Elements.
XML Document Type Definitions ( DTD ). 1.Introduction to DTD An XML document may have an optional DTD, which defines the document’s grammar. Since the.
1 XML DTD & XML Schema Monica Farrow G30
3 November 2008CIS 340 # 1 Topics To define XML as a technology To place XML in the context of system architectures.
XML Study-Session: Part II Validating XML Documents.
Document Type Definition DTDs CS-328. What is a DTD Defines the structure of an XML document Only the elements defined in a DTD can be used in an XML.
CS 898N – Advanced World Wide Web Technologies Lecture 21: XML Chin-Chih Chang
Review Writing XML  Style  Common errors 1XML Technologies David Raponi.
Introduction to XLink Transparency No. 1 XML Information Set W3C Recommendation 24 October 2001 (1stEdition) 4 February 2004 (2ndEdition) Cheng-Chia Chen.
A Technical Introduction to XML Transparency No. 1 XML quick References.
Creating a Well-Formed Valid Document. 2 Objectives Introducing XHTML Creating a Well-Formed Document Creating a Valid Document Creating an XHTML Document.
XML(EXtensible Markup Language). XML XML stands for EXtensible Markup Language. XML is a markup language much like HTML. XML was designed to describe.
XML Verification Well-formed XML document  conforms to basic XML syntax  contains only built-in character entities Validated XML document  conforms.
Document Type Definitions. XML and DTDs A DTD (Document Type Definition) describes the structure of one or more XML documents. Specifically, a DTD describes:
VALIDATING AN XML DOCUMENT
Introducing XHTML: Module B: HTML to XHTML. Goals Understand how XHTML evolved as a language for Web delivery Understand the importance of DTDs Understand.
Introduction to XML This material is based heavily on the tutorial by the same name at
Introducing HTML & XHTML:. Goals  Understand hyperlinking  Understand how tags are formed and used.  Understand HTML as a markup language  Understand.
XML Validation I DTDs Robin Burke ECT 360 Winter 2004.
Tutorial 3: XML Creating a Valid XML Document. 2 Creating a Valid Document You validate documents to make certain necessary elements are never omitted.
XP New Perspectives on XML Tutorial 3 1 DTD Tutorial – Carey ISBN
Pemrograman Berbasis WEB XML part 2 -Aurelio Rahmadian- Sumber: w3cschools.com.
Validating DOCUMENTS with DTDs
XP Tutorial 9New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with XHTML Creating a Well-Formed Valid Document Tutorial 9.
ULI101 – XHTML Basics (Part II) What is Markup Language? XHTML vs. HTML General XHTML Rules Block Level XHTML Tags XHTML Validation.
Session III Chapter 7 – Entities and Notation in DTD’s
Introduction to XML cs3505. References –I got most of this presentation from this site –O’reilly tutorials.
XP 1 CREATING AN XML DOCUMENT. XP 2 INTRODUCING XML XML stands for Extensible Markup Language. A markup language specifies the structure and content of.
Document Type Definitions Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
1 herbert van de sompel CS 502 Computing Methods for Digital Libraries Cornell University – Computer Science Herbert Van de Sompel
XML 1 Enterprise Applications CE00465-M XML. 2 Enterprise Applications CE00465-M XML Overview Extensible Mark-up Language (XML) is a meta-language that.
XML Syntax - Writing XML and Designing DTD's
TEXT ENCODING INITIATIVE (TEI) Inf 384C Block II, Module C.
XP 1 DECLARING A DTD A DTD can be used to: –Ensure all required elements are present in the document –Prevent undefined elements from being used –Enforce.
What is XML?  XML stands for EXtensible Markup Language  XML is a markup language much like HTML  XML was designed to carry data, not to display data.
XML (2) DTD Sungchul Hong.
Processing of structured documents Spring 2002, Part 2 Helena Ahonen-Myka.
1 Tutorial 13 Validating Documents with DTDs Working with Document Type Definitions.
Avoid using attributes? Some of the problems using attributes: Attributes cannot contain multiple values (child elements can) Attributes are not easily.
Unit 2, cont. September 12 More HTML. Attributes Some tags are modifiable with attributes This changes the way a tag behaves Modifying a tag requires.
Lecture 6 XML DTD Content of.xml fileContent of.dtd file.
1 Chapter 10: XML What is XML What is XML Basic Components of XML Basic Components of XML XPath XPath XQuery XQuery.
Copyrighted material John Tullis 10/17/2015 page 1 04/15/00 XML Part 3 John Tullis DePaul Instructor
XML 2nd EDITION Tutorial 1 Creating An Xml Document.
CIS 451: XML DTDs Dr. Ralph D. Westfall February, 2009.
IS432: Semi-Structured Data Dr. Azeddine Chikh. 4. Document Type Definitions (DTDs)
XML Documents Chao-Hsien Chu, Ph.D. School of Information Sciences and Technology The Pennsylvania State University Elements Attributes Comments PI Document.
IS432 Semi-Structured Data Lecture 2: DTD Dr. Gamal Al-Shorbagy.
Definition CSS “Short for Cascading Style Sheets, a new feature being added to HTML that gives both Web site developers and users more control over how.
4 Chapter Four Introduction to HTML. 4 Chapter Objectives Learn basic HTML commands Discover how to display graphic image objects in Web pages Create.
XML Instructor: Charles Moen CSCI/CINF XML  Extensible Markup Language  A set of rules that allow you to create your own markup language  Designed.
Lecture 16 Introduction to XML Boriana Koleva Room: C54
1 Introduction to XML XML stands for Extensible Markup Language. Because it is extensible, XML has been used to create a wide variety of different markup.
An Introduction to XML Sandeep Bhattaram
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Understanding How XML Works Ellen Pearlman Eileen Mullin Programming the.
Tutorial 13 Validating Documents with Schemas
Introduction to XML February 07, From HTML to XML As mentioned in previous classes, if you know HTML, then you already know XML… really! In this.
INFSY 547: WEB-Based Technologies Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
XML CSC1310 Fall HTML (TIM BERNERS-LEE) HyperText Markup Language  HTML (HyperText Markup Language): December  Markup  Markup is a symbol.
XML DTD. XML Validation XML with correct syntax is "Well Formed" XML. XML validated against a DTD is "Valid" XML.
XP Tutorial 9New Perspectives on HTML and XHTML, Comprehensive 1 Working with XHTML Creating a Well-Formed Valid Document Tutorial 9.
Document Type Definition (DTD) Eugenia Fernandez IUPUI.
XML CORE CSC1310 Fall XML DOCUMENT XML document XML document is a convenient way for parsers to archive data. In other words, it is a way to describe.
XML Schema – XSLT Week 8 Web site:
CITA 330 Section 2 DTD. Defining XML Dialects “Well-formedness” is the minimal requirement for an XML document; all XML parsers can check it Any useful.
Extensible Markup Language (XML) Pat Morin COMP 2405.
XML QUESTIONS AND ANSWERS
New Perspectives on XML
Document Type Definition (DTD)
Presentation transcript:

The Official 2002 XML Marathon April 4, 2002

Revised Requirements A photocopy of the original text A short description (read: single paragraph) discussing your choice of text and any challenges that you encountered. A completed DTD (internal or external) A completed valid and well-formed XML document (refer to our previous class for definitions of valid and well-formed XML)

Revised XML Plan Please keep in mind that XML is all about structure and to a much lesser extent presentation. It is about what is ‘under the hood’. Remember XML is all about simplicity, portability, and readability. To this effect, you will no longer be required to use pictures, links, or multimedia. You may choose to use pictures, but links and multimedia--for which there is a wealth of different protocols--will not be covered in the time remaining.

The XML Marathon Covering the following: –The Official XML Refresher –Defining and incorporating entities –Working with empty tags (including use of images) –Oh, the places you’ll go: Advanced XML and Beyond!

XML Refresher The Plan: –Before you do anything, take your project document and break it down, from its overall largest structure (e.g., book) to its simplest or smallest structure (e.g., sub-sub-sub-sub-heading). –Devise your own XML names for defining these structural elements (remember your time-o-gram) and, if you wish, presentation elements as well (e.g., or ).

Document or DTD Your next step is up to you, but you have two choices: –You can immediately start in on creating your DTD using the elements you have discovered, or, –You can begin marking up your XML document, taking the raw text you have to work with and diving right into it. –Both methods are perfectly acceptable.

Building XML When creating your XML document, remember the first steps: –Declare the XML Version ( ) –Define your DTD, either: include it as an internal DTD, or reference it (we’ll go over these in a minute) –Begin your XML with your ROOT element (e.g., book). –Make this your mantra: Version-DTD-Root

Choosing a DTD style Internal –Simple and compact –Applies to only one document External –A little more complex (one more line of XML!) –Can apply to any number of documents –Harder to work with (navigating between multiple screens, flipping back and forth between docs)

Real-World DTDs Internal –A single independent document that has only one purpose or application (e.g., only viewed online) External –A document or series of documents that can be re- purposed (e.g., online, print, database, , etc.) –Cuts down on duplication and coding time.

Your Project DTD The choice of which style of DTD to use is completely up to you. Internal Example: <!DOCTYPE book [ … ]> External Example:

Defining Elements and Attributes A DTD must define rules for each and every element and attribute that will appear in your XML document. Otherwise, it will not be valid. Whenever you change your XML, remember to make the corresponding changes to your DTD, particularly if you are adding elements or attributes to your document.

Also remember.. At any time in your document, you can create comments for yourself or for others. This will be useful for those of you involved in the showcase! Comments are create by using the start and end tags, such as:

Defining Structure Defining our root element – –Like a tree hierachry: book (root element) chapteronechaptertwo sectionone sectiontwo … … … … … … … … … … … … … Always remember that XML is case-sensitive!

Defining Text To define an element to contain text: –Type <!ELEMENT yourtag where yourtag is the tag you are creating and wish to define. –Next, type a space and (#PCDATA)> –This states that the element you define will only contain text –PCDATA stands for parsed character data and refers to everything except your XML code. Example:

Defining Elements… cont’d So, for example, your DTD will contain structural elements, such as your root element, which describes what other elements are contained within it, as well as textual elements that contain only text: ….

Defining Constraints Also remember that it is possible to put constraints on the number of times that a given element can appear in your document (e.g., you don’t want 2 book titles), using the symbols: ? + * Example: Here we limit so that it can only appear once, as well as indicating that a book must have at least one, and that a book can contain as many s as necessary.

Attributes Remember that information contained in attributes tends to be about your XML document, rather than your content. They are primarily metadata. Users rarely see attributes: they are primarily used by parsers and XML designers. Attributes are very commonly used with empty elements to point or link to the content of the element.

Attributes… cont’d To define attributes: –Type <!ATTLIST yourtag where yourtag is the name of the element in which the attribute will appear. –Type the name of the attribute –Then, either type CDATA (not #PCDATA) for any combination of numbers or text (basically anything), or type ( value1 | value2 | etc.) where either value1 or value2 (etc.) is the ONLY value acceptable. –Finally, you must type one of the following: “ value” where value will be the default value if none is explicitly set “#FIXED value ” where value is the default and ONLY value for that attribute (i.e., it is fixed) “#REQUIRED” to specify that the attribute must contain some (not pre- specified value) Or, “#IMPLIED” to specify that there is no default value, and the value may be omitted if desired.

Attribute examples This attribute definition says that the date element may contain an optional (#IMPLIED) year attribute that contains any number of characters (CDATA). This attribute definition says that the date element must be used (#REQUIRED) and that the value must be one of 1999, 2000, 2001, or Those are the only choices (from value list).

Any Questions?

Defining Entities Entities are essentially acronyms that you create to stand for a string of text (e.g., slis for School of Library and Information Studies). They allow you to code your document using the acronym instead of the long-form, and then when the document is parsed, it substitutes your acronym for the long-form on the fly. So a parser encountering EFF would, based on the Entity’s definition in the DTD, replace it with Electronic Frontier Foundation.

More on Entities There are two kinds of Entities: general entities and parameter entities. We are going to concentrate on general entities, which load data into the XML document itself, rather than parameter entities, which load data into your DTD. General entities are also sometimes called ‘shortcuts’.

Creating Entities To create an Entity: –In your DTD, type <!ENTITY and add a space –Next, type in your acronym and another space (e.g., EFF) –Lastly type the long-form of your text in quotation marks (e.g., “Electronic Frontier Foundation”) and finish the tag with a > Example:

Using Entities Once you have created your Entities, in order to activate them within your XML document, you need to build a command using the ampersand, your acronym, and the semi-colon: For example: –The &eff; has been protecting the digital rights of online user groups since The &eff; is currently involved in litigation concerning…

External Entities If you have cause to create large Entities (e.g., whole paragraphs or pages of text), you are better of creating external Entities, where the bulk of the Entity will not affect the speed at which your XML is loaded or parsed. This practice also allows you to share Entities with other documents.

Creating External Entities First, create the Entity itself in an external text file. Second, if you were using an internal DTD, you will need to add the following attribute to your XML declaration: standalone=“no” Next, type <!ENTITY and a space Then, your acronymn and another space Then, SYSTEM, a space, and in quotation marks, the location and name of the file (e.g., “docs/entity.txt” or simply “entity.txt”) Close the tag with a >

Using External Entities Example: To use the Entity in your XML document, again use the ampersand (&) and semi-colon (;), for example: The &eff; had the following to say about the event: &effpara;

Entities for Unparsed Content We can also use Entities to load unparsed content into our XML. Unparsed content can include all sorts of multimedia, including images. Unparsed Entities can also be used to embed non-text or non-XML content into an XML document.

Creating Unparsed Entities In your DTD, type <!ENTITY and a space Next, type your desired acronym (e.g., effpict) Next, type SYSTEM, a space, and in quotation marks the location and name of the file you want to loan (e.g., “img/effpict.jpg”). Next, type NDATA id where id is the word that identifies the notation that will describe the unparsed data (we’ll do this next). Close the tag with a >

Unparsed Entities… cont’d Example: – Again, all Entities are used in XML by using the same & and ; signs –For example: &effpict;

Entity Notation Because an Unparsed Entity can contain anything, it requires that a Notation be created to give some definition to your entity. Usually, the Notation includes a word describing the file type or content of the Entity. It is purely metadata. To create the Notation, you add another simple tag to your DTD immediately following your Unparsed Entity.

Creating Notations On a new line in your DTD, type <!NOTATION and a space Next, type id where id is the name you used to identify it in the !ENTITY tag (e.g., picture) and a space Next type SYSTEM, a space, and then in quotations the content information you are going to provide (e.g., “jpg/jpeg”) Close the tag using a > Example:

A Simpler Image There is, however, a simpler method of including an image in your XML. It involves using an EMPTY Elements (not Entities). EMPTY elements often express unparsed content (i.e., content that cannot be written out in text) such as multimedia. To use an EMPTY Element, you must first define an new element in your DTD (e.g., )

Simpler Image… cont’d However, just like the tag in HTML, the EMPTY element requires an attribute telling it where to find the image (e.g., filename=“effpict.jpg”) To create the attribute, use the format: –, or –

Image Example So, your DTD should include something like the following: Your corresponding XML should look like: or,

Closing EMPTY elements XML allows for EMPTY elements to be closed in the traditional manner, using a forward slash ( ), or by including the forward slash as the last character in the opening tag ( ). The choice to use one or another is left to the designer.

Any Questions?