1 / 13

Class Overview

Class Overview. DTD Project discussion Visual Studio .NET Assignment 1. DTD’s. This the “syntax” of an XML document. The structure (elements, etc) of an XML document are specified by a “schema”. If an XML document adheres to a prespecified

benjy
Download Presentation

Class Overview

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Class Overview • DTD • Project discussion • Visual Studio .NET • Assignment 1

  2. DTD’s .... This the “syntax” of an XML document. The structure (elements, etc) of an XML document are specified by a “schema”. If an XML document adheres to a prespecified schema, it is valid....ie the syntax is compliant with the schema. Schemas are specified by DTD’s or XML Schema. We’ll look at both DTD’s and XML Schema next.

  3. The role of XML Request CGI, PHP, VB, etc Database, web service etc XML document Parse, validate Application DTD or XML Schema Application uses content (for presentation CSS) or other kind of application (web service) XML doc is parsed and possibly validated by parser Formatting is done in compliance with XML schema or DTD Data is formatted into an XML doc

  4. Different types of DTD’s Internal DTD - inside .xml file <?xml version=“1.0”?> <!DOCTYPE people [ .... ]> <people> </people> External DTD - file with .dtd extension <!ELEMENT ......> “SYSTEM” (private) vs “PUBLIC” Local extensions,rules can be added to external reference and override the external DTD.

  5. Using a DTD from within an .xml <?xml version=“1.0” standalone=“no”?> <!DOCTYPE people SYSTEM “http://www.dartmouth.edu/~gvc/..”> <people> ... </people> Naming DTD’s using Formal Public Identifiers (FPI’s)..... Next class....structure of the DTD and XML Schema.

  6. Defining elements <!ELEMENT people(name,company)> Elements name and company must be defined elsewhere, before, after or externally. <!ELEMENT people(name+, company*)> means name occurs at least once, company zero or more times. <!ELEMENT nameandcomp(name|company)> <!ELEMENT people(name|nameandcomp*)> + means at least once, ? means zero or one, * means zero or more so (name,name,name+) means at least three time, etc.

  7. Kinds of Elements • <!ELEMENT weather(temp, wind, precip)> - as before • <!ELEMENT photo EMPTY> - attributes only • <!ELEMENT people ANY> - any elements allowed! • <!ELEMENT temp (#PCDATA)> • <!ELEMENT wind (#PCDATA)> • #PCDATA indicates text (leaf element)

  8. Defining Attributes <!ELEMENT weather(temp, wind, precip)> <weather units=“US”> <temp....</weather> <!ATTLIST weather units xxx yyy> weather - element for which attribute declared units - name of attribute for weather xxx - either PCDATA or (US|INT) yyy - either default or #FIXED “default” or #REQUIRED or #IMPLIED

  9. Defining Attributes default - value if not specified #FIXED “default” - value it must be if specified #REQUIRED - not optional #IMPLIED - optional, no default value Precede by “ID” if value is required to be unique for all attributes in the XML document, see also IDREF

  10. Defining Entities (Macros) <!ENTITY MS “Microsoft Corporation”> In an XML document... <company>&MS;</company> expands to <company>Microsoft Corporation</company> when parsed.

  11. Defining External Entities File ms.ent contains Microsoft Corporation, Redmond, WA In DTD file, abc.dtd put <!ENTITY MS SYSTEM “ms.ent”> In the XML document... <?xml version=“1.0” standalone=“no”?> <!DOCTYLE company SYSTEM “http://www.x.edu/pub/abs.dtd”> .... <company>&MS;</company> expands to <company>Microsoft Corporation, Redmond, WA</company>

  12. Defining External Entities File entity.dtd contains an element declaration. In another DTD file, abc.dtd put <!ENTITY % MS SYSTEM “entity.dtd”> In the XML document... <?xml version=“1.0” standalone=“no”?> .... %MS; .... Non-parsed entities....read about them on your own... XML Schema is another way to declare XML structure....do it on your own. Brown XML validator http://www.stg.brown.edu/pub/xmlvalid/

  13. Project Discussion • Class project • description/goals • resources • schedule/milestones • assignments • deliverables

More Related