webdb xmlIntro

56 %
44 %
Information about webdb xmlIntro
Education

Published on January 15, 2008

Author: Dario

Source: authorstream.com

A web database transaction example…:  Client request Server response 2. Web server decodes and validates request 3. Application server executes business logic associated with resource 4. Connection made to database server 1. Client adds request headers to URI and sends to server 5. Database server executes any stored procedures, SQL, etc. and sends results back up the stream 6. Application server may execute additional logic 7. Web server adds response headers and sends back to client 1. 2. 3. 4. 5. 6. 7. A web database transaction example… Markup Example:  Markup Example (doc) (title) XML Fundamentals (.title.) (para) Pieces and Parts (list) (list_item importance="critical") elements (list_item importance="optional") attributes (list_item) others? (.list.) (para) Rules for use (.doc.) Is this valid markup? What about…? <msg /> What is a Markup Language?:  What is a Markup Language? Textual annotations Structural (aka “Logical”) "Semantic role" of text Examples: STRONG, P, H1 Semantic and organizational structure Physical (aka “Typographic”) How text should look Examples: B, I, CENTER Display and formatting HTML Examples:  HTML Examples Elements and Attributes <img src="http://ils.unc.edu/~chafk/images/line4.gif" width="623" height="11”> <a href="http://ils.unc.edu/chaffin/157/">Click me!</a> Entities <td> &nbsp; </td> “&nbsp;” says to place here an externally stored piece of text, in this case the “white space character” as generated by the space bar on your keyboard Other entities include things like: &lt; &amp; &quot; Defining XML:  Defining XML XML is a language to create other languages (meta-language) Tagged based markup language (like HTML) and tags describe the data they contain (communities can agree upon the set of allowable elements) Separate structure from formatting. Syntax is much more rigid than HTML Easy for browsers to display Elements, attributes, and values:  Elements, attributes, and values <?xml version="1.0" ?> <!-- this file is an excerpt from an endangered species list --> <animal> <name language=“English”>Tiger</name> <name language=“Latin”>Panthera tigris</name> <weight>&lt;500 pounds</weight> <picture filename=“tiger.jpg”/> </animal> Empty elements contain all data as values of their attributes, rather than enclosing text or pointing to an external file location Non-empty elements enclose parsed character data (aka. a text node in XPath) XML--Key Concepts:  XML--Key Concepts Well-formed document Tags valid, consistent with good XML coding Unambiguous mark-up allows XML processor to discover the document structure Valid document Well-formed Validated against an associated Document Type Definition (DTD) A Document is a logical structure in XML Well-formed XML:  Well-formed XML Must have a single root element (document element) Contains all other elements (parents and children) Only processing instructions and comments are allowed outside of the root element Processing instructions start with <? And end with ?> Comments are designated with <!-- and --> Closing tags are required Either <tag>…</tag> or <tag attribute=“…”/> (aka. empty element) Elements can’t overlap – they must be properly nested (can be nested as deeply as necessary though) Case matters! Values must be enclosed in quotes Matched, though single or double doesn't matter Entity references must be declared in a DTD Not Well-Formed Example:  Not Well-Formed Example <photo_album> <page> <picture color = yes> <subject>Sasha <size>wallet </picture> </size> </page> <page> </page> </Photo_Album> Well-formed Example:  Well-formed Example <photo_album> <page> <picture color =“yes”> <subject>Sasha</subject> <size>wallet</size> </picture> </page> <page> </page> </photo_album> photo_album page page picture subject size Sasha wallet Writing Valid XML:  Writing Valid XML <?xml version=“1.0” standalone=“no” ?> <!DOCTYPE simpledoc SYSTEM “http://xx.yy.com/simpledoc.dtd”> <!-- This is a simple XML document that references a DTD held elsewhere --> <simpledoc> I am a simple document, but not stupid. </simpledoc> Use external DTD Here it is So, you may well ask, what exactly does that DTD file look like? Well, first we need to back up and talk about… Say this is a file called simple.xml (It's both well-formed and valid):… Schemas:  Schemas Defines the set of allowed tags in an XML application Communities can agree on their own specific schemas (several are currently available) Specifies required tags Two methods to write schemas DTDs – Document Type Definition XML Schema – developed by the W3C XMLSchema:  XMLSchema Alternative validation (vs. DTD) W3C XML Schemas Microsoft XML Schemas Limitations of DTDs Not written in XML Don’t support namespaces For more info: http://www.w3.org/2001/XMLSchema So just what does that DTD look like?:  So just what does that DTD look like? <?xml version="1.0" ?> <endangered_species> <animal> <name language=“English”>Tiger</name> <name language=“Latin”>Panthera tigris</name> <weight>&lt;500 pounds</weight> <picture filename=“tiger.jpg”/> </animal></endangered_species> We could make this reference a specified schema by either changing our xml file by adding an internal DTD such as:: <?xml version=“1.0” ?> <!DOCTYPE endangered_species [ DTD SPEC GOES HERE… ]> <endangered_species><animal> … </animal></endangered_species> Or adding a reference to an external DTD by doing this: <?xml version=“1.0” standalone=“no” ?> <!DOCTYPE endangered_species SYSTEM “http://ils.unc.edu/chaffin/xml/end_species.dtd”> <endangered_species><animal> … </animal></endangered_species> Typical DTD declaration:  Typical DTD declaration <!ELEMENT endangered_species (animal*)> <!ELEMENT animal (name+,weight?,picture,endangered?)> <!ELEMENT name(#PCDATA)> <!ATTLIST name language (English|Latin) #REQUIRED> <!ELEMENT weight (#PCDATA)> <!ELEMENT picture EMPTY> <!ATTLIST picture filename CDATA #REQUIRED> <!ELEMENT endangered (yes|no)> Quantifiers: * - 0 to many ? - 0 or 1 + - 1 to many No quantifier indicates one and only one What is #PCDATA anyway? And what about CDATA?

#pcdata presentations

Add a comment

Related presentations

Related pages

Database Processing with XML - Ace Recommendation Platform

Ace your next Database Processing with XML test with these study tools from Learning Ace!
Read more

XML数据管理技术地研究.pdf 57页 - XML数据管理 ...

M.,Anintroductionto theSetansible Bryan Markup http:llwww.personal.U-net.corrd-sgml/xmlintro.htm ... 1999 Databases WebDB‘99 ...
Read more