XML Fundamentals Namespaces Data Warehousing Lab XML Fundamentals
XML Fundamentals , Namespaces Data Warehousing Lab. 박유림
XML Fundamentals 1. HTML vs XML 1. Html: limited to about a hundred predefined tags 2. XML : you can create as many tags as you need 2. XML is looser than HTML in regards to which tags it allows, it is much stricter about where those tags are placed and how they’re written. 3. Easy & Flexibility 2 DW Data Warehousing Lab.
XML Documents and XML Files 1. XML document contains text, never binary data. 1. Ex)file name: person. xml <person> Alan Turing </person> 2. Your operating system may or may not like these names, but an XML parser won’t care. 3 DW Data Warehousing Lab.
Elements, Tags, and Character Data 1. Element’s content, Markup, Character data <person> Alan Turing </person> 1. Everything between the start-tag and the end-tag of the element : element’s content Markup 3. Character data 2. Tag Syntax 1. Empty elements : ex) <hr></br> 2. Case sensitivity : <PERSON> <person> 4 DW Data Warehousing Lab.
XML Trees <person> <name> <first_name>Alan</first_name> <first_name>Turing</last_name> </name> <profession>computer scientist</profession> <profession>mathematician</profession> <profession>cryptographer</profession> </person> n Parents and children : one parent element n The root element : contains all other elements 5 DW Data Warehousing Lab.
XML Name & Entity References… I 1. XML name 2. Entity References 3. CDATA Sections 1. <!CDATA[ and ]]> 4. Comments 6 1. <!-- This is comment text --> 2. -- should not appear anywhere inside the comment until the closing DW Data Warehousing Lab.
XML Name & Entity References… II 1. Processing Instructions. 1. Processing instruction as an alternative means of passing information to particular applications that may read the document 2. <? xml-stylesheet href=“person. css” type=“text/css”? > <person> Alan turing </person> 2. XML Declaration 1. 7 XML declaration looks like a processing instruction with the name xml and version, standalone, and encoding attributes. DW Data Warehousing Lab.
XML Name & Entity References… III 1. XML Declaration <? xml version=“ 1. 0” encoding=“ASCII” standalone=“yes”? > <person> Alan turing </person> <? xml-stylesheet href=“person. css” type=“text/css”? > <person> Alan turing </person> 8 DW Data Warehousing Lab.
Checking Documents for Well. Formedness 1. Every start-tag must have a matching end-tag 2. Elements may nest, but may not overlap 3. There must be exactly one root element 4. Attribute values must be quoted 5. An element may not have two attributes with the same name 6. Comments and processing instructions may not appear inside tags 7. No unescaped < or & signs may occur in the character data of an element or attribute 9 DW Data Warehousing Lab.
Namespaces 1. Purpose in XML 1. To distinguish between elements and attributes from different vocabularies with different meanings and that happen to share the same name 2. To group all the related elements and attributes from a single XML application together so that software can easily recognize them. 3. <a: title> vs <b: title> 2. Namespace Syntax 1. Qualified Names, Prefixes, and Local Parts 1. Ex) rdf : description xlink : type 10 DW Data Warehousing Lab.
Binding Prefixes to URI 1. Binding prefixes to uri 1. Each prefix in a qualified name must be associated with a URI. 2. Ex) <rdf: Description xmlns: dc=“http: //purl. org/dc/” about=“http: //www. cafeconleche. org/examples/impressionists. xml”> 11 DW Data Warehousing Lab.
Namespaces and DTDs n A document can have a DTD but not use namespaces or use namespaces but not have a DTD. n The name of the element in the document must exactly match the name of the element in the DTD including the prefix. 12 DW Data Warehousing Lab.
- Slides: 13