Presentation is loading. Please wait.

Presentation is loading. Please wait.

3. Document Type Definitions(DTDs) Data Warehousing Lab. 윤 혜 정.

Similar presentations


Presentation on theme: "3. Document Type Definitions(DTDs) Data Warehousing Lab. 윤 혜 정."— Presentation transcript:

1 3. Document Type Definitions(DTDs) Data Warehousing Lab. 윤 혜 정

2 2 Data Warehousing Lab. DW Validation n The document must match a declaration in the DTD. n The document satisfies the DTD then the document is said to be valid. n The DTD lists all the l Elements l Attributes l Entities

3 3 Data Warehousing Lab. DW A Simple DTD Example DTD Examples : XML Examples : Valid Alan Turing XML Examples : NOT Valid : omits the name computer scientist mathematician cryptographer XML Examples : NOT Valid : profession elements comes before name computer scientist Alan Turing XML Examples : NOT Valid : add a publication element Alan Turing computer scientist cryptographer On computable Numbers…. XML Examples : NOT Valid : add some text outside the allowed children Alan Turing was a computer scientist a cryptographer, and a

4 4 Data Warehousing Lab. DW The Document Type Declaration n The Document Type Declaration http://www.cafeconleche.org/dtds/person.dtd n Internal DTD subsets & External DTD subsets p between the brackets is called the internal DTD p come from outside this documents are called external DTD n Validating a Document p XML validation Form : The Brown University Scholarly Technology Group’s XML validation Form : The Brown University Scholarly Technology Group’s p XML well-formedness checker and validator : Richard Tobin XML well-formedness checker and validator : Richard Tobin

5 5 Data Warehousing Lab. DW Element Declarations n In a DTD, XML elements are declared with a DTD element declaration. n Basic form n Content_specification p Empty elements : EMPTY p Elements with only character data : #PCDATA p Elements with any contents : ANY p Elements with children (sequences) p The Number of Children p Choice p Mixed Content

6 6 Data Warehousing Lab. DW Attribute Declarations n A valid document must declare all the element’s attributes. n ATTLIST declarations n A single ATTLIST can declare multiple attributes for a single element type. Example : width CDATA #REQURED>

7 7 Data Warehousing Lab. DW Attribute Declarations n Attribute Type ValueExplanation CDATAThe value is character data NMTOKENThe value is valid XML name NMTOKENSThe value is a list of valid XML name EnumerationThe value is a list of possible values for attribute ENTITYThe value is an entity ENTITIESThe value is a list of entities IDThe value is a unique id IDREFThe value is the id of another element IDREFSThe value is a list of other ids NOTATIONThe value is name of notation

8 8 Data Warehousing Lab. DW Attribute Declarations n Default value TypeExplanation Default valuesThe default value of the attribute #REQUIRED The attribute value must be include in the element #IMPLIEDThe attribute does not have to be include #FIXEDThe attribute is fixed

9 9 Data Warehousing Lab. DW Entities n Entities are storage containers used to hold data. n Entities are variables used to define shortcuts to common text. n The predefines five entities <( ), "(“), &apos;(‘) n Entities can be declared “ internal or external”, “parsed or unparsed”, “general or parameter”.

10 10 Data Warehousing Lab. DW Entities n Internal vs. External n Parsed vs. Unparsed n General vs. Parameter TypeDeclared inUsed inAlways Parsed? Internal GeneralInternal DTDXML DocYes External GeneralExternal DTDXML DocNo Internal ParameterInternal DTD Yes External ParameterExternal DTD Yes

11 11 Data Warehousing Lab. DW External Parsed General Entities n Enable you to store some of your XML document in a separate file, making it reusable across multiple XML documents. n Gives you a chunk of reusable code. n Declared in the DTD using an ENTITY declaration. n SYSTEM or PUBLIC SYSTEM : document containing the contents of the entity is unregistered PUBLIC : document is registered. n Using External Parsed General Entities an ampersand(&) and followed by a semicolon(;);  &footer Example : http://www.oreilly.com/boilerplate/footer.xml

12 12 Data Warehousing Lab. DW External Unparsed General Entities n XML parser will not try to parse the entity’s contents. n Data within the entity is ignored by the XML parser and passed to the application that is using the document. n Notations used by the application to identify the type of data in entity. n Declaring an External Unparsed General Entity <!ENTITY turing_getting_off_bus SYSTEM http://www.turing.org.uk/turing/pi1/bus.jpghttp://www.turing.org.uk/turing/pi1/bus.jpg NDATA jpeg>

13 13 Data Warehousing Lab. DW External Unparsed General Entities n Embedding Unparsed Entities in Documents n Using External Unparsed Entities

14 14 Data Warehousing Lab. DW Parameter Entities n Used within the DTD and must “parsed Entity ” n Using parameter Entities an percent(%) and followed by a semicolon(;) n Example

15 15 Data Warehousing Lab. DW Parameter Entities

16 16 Data Warehousing Lab. DW Conditional Inclusion XML offers the IGNORE directive for the purpose of “commenting out” a section of declaration. <![ 긴급 [ <!ENTITY 추신 “ 매우 긴급하오니 반드시 3 일내에 답장해 주십시요 ” ]]> <![ 보통 [ ]]> <!DOCTYPE 팩스 SYSTEM “ 팩스.dtd”[ ]> …. & 추신


Download ppt "3. Document Type Definitions(DTDs) Data Warehousing Lab. 윤 혜 정."

Similar presentations


Ads by Google