SlideShare uma empresa Scribd logo
1 de 29
XML For Dummies Book Author : Lucinda Dykes & Ed Tittle Slides Prepared By: Son TN Chapter 8 :Understanding and Using DTDs
Contents What ‘s a DTD ? Inspecting the XML Prolog Reading a DTD Using Element Declarations Declaring Attributes Understanding Notations Calling a DTD
8. 1. What’s a DTD ? Document Type Definition (DTD) Defines the syntax, grammar & semantics  Defines the document structure What Elements, Attributes, Entities, etc are permitted? How are the document elements related & structured? Referenced by or defined in XML documents, but it’s not XML!  Enables validation of XML documents using an XML Parser. Can be referenced to by more than one XML document. DTD’s may reference other DTD’s
 1. What’s a DTD ? (Cont) Table 8-1 deciphers some of the terms
8.1.1 When to use a DTD XML doesn’t require you to use a DTD Including DTDs in a document is to decide whether you want to jump off that particular bridge. Several reasons to use DTD: To create and manage large sets of documents for your company. To define clearly what markup may be used in certain documents and how markup should be sequenced. To provide a common frame of reference for documents that many users can share. Standardization and control are what they’re all about!
8.1.2 When NOT to use a DTD You may not need to use a DTD if: You’re working with only one or a few small documents. You’re using a nonvalidating processor to handle your XML documents. Let the XML documents or data that you work with drive you toward or away from creating formal document descriptions.
8.2 2. Inspecting the XML Prolog The XML prolog is the first thing that a processor — or human eye, for that matter — sees in an XML document An XML prolog may include the following items XML declaration DOCTYPE declaration Comments Processing instructions White space The XML declaration.
8.2.1 Examining the XML declaration A declaration is markup that tells an XML processor what to do. Declarations don’t add structure or define document elements. They provide instructions for a processor, such as what type of document to process and what standards to use. The XML declaration can include version, encoding, and/or standalone attributes: This is an XML document. The version of XML is XML 1.0. The character encoding is UTF-8. An external document may be needed to complete the document content (standalone=”no”). <?xml version=”1.0” encoding=”UTF-8” standalone=”no”?>
8.2.2 Discovering the DOCTYPE The document type (DOCTYPE) declaration is markup that tells the processor where it can find a specific DTD. Here’s the basic markup of a DOCTYPE declaration: <!DOCTYPE marks the start of the DOCTYPE declaration. Books is the name of the DTD used. SYSTEM “bookstore.dtd” tells the processor to fetch an external document — in this case, a file named bookstore.dtd. <!DOCTYPE books SYSTEM “bookstore.dtd”>
8.2.3 Understanding comments Comments — use them and read them! Use comments to include text that explains a document better (humans love that sort of thing) without that text being displayed — or even processed. The correct format is: You have two rules to live by when you’re using comments: Never nest a comment inside another element. Never include - (hyphen) or -- (double hyphen) within the comment text. Using comments enables you to leave human-style instructions (that is, comments) addressed to someone who reads the markup without disrupting the document’s structure. <!-- comment text --> <!-- Include your comment here -->
8.2.4 Processing instructions Processing instructions are like comments addressed to machines; they provide a way to send instructions to computer programs or applications. All processing instructions follow this format: A common example of a processing instruction in XML documents is a reference to stylesheets. All processing instructions must begin with <? and end with ?>. <?name data?> <?xml:stylesheet type=”text/css” href=”bookstore.css”?>
8.2.5 How about that white space? XML considers four characters to be whitespace: the carriage return ( or ch(13)), the linefeed ( or ch(10)), the tab(), and the spacebar (' ').  In XML documents, there are two types of whitespace:  Significant whitespace is part of the document content and should be preserved. Insignificant whitespace is used when editing XML documents for readability.  The XML specification allows you to add white space outside markup; it’s ignored when the document is processed When you write markup, consider adding a line of white space between sections.
8.3. Reading a DTD ,[object Object],<?xml version=”1.0” encoding=”UTF-8”?> <!ELEMENT books (book+, totalCost, customer)> <!ELEMENT book (bookInfo, salesInfo)> <!ATTLIST book contentType (Fiction | Nonfiction) #REQUIRED format (Hardback | Paperback) #REQUIRED> <!ELEMENT bookInfo (title, author, publisher, isbn)> <!ELEMENT title (#PCDATA)> <!ELEMENT author (#PCDATA)> <!ELEMENT publisher (#PCDATA)> <!ELEMENT isbn (#PCDATA)> <!ELEMENT salesInfo (price, itemNumber, date, source, shipping, cost)> <!ELEMENT price (#PCDATA)> <!ATTLIST price priceType (Retail | Wholesale) #REQUIRED> <!ELEMENT itemNumber (#PCDATA)> <!ELEMENT date (#PCDATA)> <!ELEMENT source EMPTY> <!ATTLIST source sourceType (Retail | Wholesale) #REQUIRED> <!ELEMENT shipping (#PCDATA)> <!ELEMENT cost (#PCDATA)> <!ELEMENT totalCost (#PCDATA)> <!ELEMENT customer (custNumber, lastName, firstName, address, city, state, zip, phone, email)> <!ATTLIST customer custType (newRetail | prevRetail | newWholesale | prevWholesale) #REQUIRED> <!ELEMENT custNumber (#PCDATA)> <!ELEMENT lastName (#PCDATA)> <!ELEMENT firstName (#PCDATA)> <!ELEMENT address (#PCDATA)> <!ELEMENT city (#PCDATA)> <!ELEMENT state (#PCDATA)> <!ELEMENT zip (#PCDATA)> <!ELEMENT phone (#PCDATA)> <!ELEMENT email (#PCDATA)> ,[object Object]
 The DTD terms must be used exactly as written below; in other words, !ELEMENT, !ATTLIST, #REQUIRED, #PCDATA, and EMPTY must all be capitalized.EMPTY must all be capitalized. ,[object Object],[object Object]
8. 4.1 Using the EMPTY element type… Empty elements are like boxes you put in place but want left empty. To use them, first you have to point them out to the processor — by declaring them. Such a declaration looks like this: In our example DTD, the source element is an empty element: If (on the other hand) you want your element to serve as a catch-all box that you can put anything in, you may want to use another type of content specification: ANY. <!ELEMENT Name EMPTY> <!ELEMENT source EMPTY>
8.4.2 Adding mixed content Mixed content allows elements to contain character data, or character data and child elements. The basic structure for a mixed-content element declaration is as follows: If the element contains only character data, then the structure looks like this: Example You can work with mixed content in one of two ways: ,[object Object]
Allow an element to contain both text and other elements (In that case, don’t forget the asterisk!<!ELEMENT Name (#PCDATA | Child1 | Child2)*> <!ELEMENT Name #PCDATA> <!ELEMENT author (#PCDATA | publisher )*>
8. 4.3 Using element content models An element content model describes the child elements that an element can contain. The basic structure is : Example  The element content model uses occurrence indicators to control the order and number of times that elements can occur. <!ELEMENT Name (childName)> <!ELEMENT books (book+)> <!ELEMENT customer (custNumber, lastName, firstName, address, city, state, zip, phone, email)>
8. 4.4 Declaring Attributes You need to include attribute-list declarations in your DTD whenever you want elements to use associated attributes. The attribute-list declaration lists all attributes that may be used within a given element and also defines each attribute’s type and default value. The basic format for an attribute-list declaration is: Example The following list defines the terms that appear in attribute-list declarations: Element name Attribute name Datatype (CDATA, or character data , ID, IDREF, IDREFS, ENTITY, ENTITIES , NMTOKEN, NMTOKENS, NOTATION, Enumrated list Default value (#REQUIRED, #IMPLIED , #FIXED , value) <!ATTLIST element-name attribute-name datatypedefaultvalue> <!ATTLIST customer custType CDATA #REQUIRED> <!ATTLIST price priceType (Retail | Wholesale) #REQUIRED>
8. 4.5 Discovering Entities An entity declaration defines an alias for a block of text. You can attach a name to a specific block of text and then insert the whole block by using just one name. An entity declaration in a DTD looks like this: entityNameis the name of the entity and is used to call up the replacement Text in your document. The two main classifications of entities are general entities and parameter entities. A general entity is an abbreviation for data that becomes part of the content of an XML document. A parameter entity is an abbreviation for data that becomes part of the content of a DTD. <!ENTITY entityName“replacementText”>
8. 4.6 General entities The XML specification supports two types of general entities: Internal entities hold their values in the entity declaration external entities point to an external file. Internal entities To declare a general internal entity, you must use the following syntax: Or <!ENTITY entityName“replacementText”> <!ENTITY store1 “River Valley Center”> Five commonly used internal entities are already defined as part of XML
8. 4.6 General entities (cont) External entities External entities help you integrate external documents and files into your XML document. In general, you use them in one of two ways: As a mechanism to divide your document into logical pieces. To reference images, multimedia clips, and other non-XML files. To declare an external entity, you use the following syntax: Use the following syntax to refer to a public identifier not stored on your system The benefit of using external entities is that they’re reusable. They are subject to three important limitations: You can’t use an entity before you define it. Your entity references have to do something. The entity has to refer to data that’s in the XML document. <!ENTITY entityNameSYSTEM “system-identifier”> <!ENTITY entityNamePUBLIC “system-identifier”>
8. 4.7 Parameter entities A parameter entity Is an entity that is created specifically for the purpose of helping you use shortcuts when you write a DTD. They don’t refer to content in XML documents at all. Parameter entities may also be internal or external. Internal entities : Internal parameter entities work well to eliminate the need to repeat commonly used element and attribute declarations. Parameter entities must be declared before they can be used. The general syntax for an internal parameter entity declaration: External entities :  Use external parameter entities to carve DTDs into bite-size bits of declarations that are easy to read and manipulate. You can then save each bit in a separate file and create a single parameter entity in the master DTD that points to each individual file. <!ENTITY % entityName “replacementText”>
8. 4.7 Parameter entities External entities : These kinds of parameter entities are called external parameter entity references because they refer to information that’s external to the DTD in which they appear. <-- Master DTD for book information, sales data, and customer information --> <!ENTITY % Bks SYSTEM “book.dtd”> <!ENTITY % Sls SYSTEM “sales.dtd”> <!ENTITY % Cust SYSTEM “customer.dtd”> %Bks; %Sls; %Cust;
8. 5. Understanding Notations In XML, you may come across data that you would like to include in your documents that is not XML.  Notations allow you to include that data in your documents by describing the format it and allowing your application to recognize and handle it.  The format for a notation is:  The name identifies the format used in the document, and the external_id identifies the notation - usually with MIME-types. For example, to include a GIF image in your XML document:  You can also use a "public" identifier, instead of "system". <!NOTATION name system "external_ID">  <!NOTATION GIF system "image/gif">  <!NOTATION GIF public  "-//IETF/NOSGML Media Type image/gif//EN"  "http://www.isi.edu/in-notes/iana/assignments/media-types/image/gif">
8. 5. Calling a DTD DTDs come in two flavors: internal and external. Internal DTDs are entirely contained in the XML prolog of an XML document. External DTDs are contained in an external file and are referenced in the DOCTYPE declaration of an XML document.
8. 5.1 Internal DTDs If your DTD is short and simple, and you don’t need to include it in a large group of XML documents, you may want to use it as an internal DTD. To add an internal DTD to your XML document, you include it within the DOCTYPE declaration Example  <!DOCTYPE rootElement [ ... the entire DTD goes here ... ] <?xml version=”1.0” encoding=”UTF-8”?> <!DOCTYPE books [ <!ELEMENT books (book+, totalCost, customer)> <!ELEMENT book (bookInfo, salesInfo)> ... ] <books> <book contentType=”Fiction” format=”Hardback”> <bookInfo> ...
8. 5.2 External DTDs Using external DTDs is a great idea, because you can then share a single DTD among any group of XML documents. To use an external DTD with an XML document, simply reference the external DTD in the DOCTYPE declaration in the XML prolog of your XML document. Example <!DOCTYPE rootElement SYSTEM dtd.url> <?xml version=”1.0” encoding=”UTF-8” standalone=”no”?> <!DOCTYPE books SYSTEM “bookstore.dtd”> <books> ...
8. 5.3 When to use an internal or external DTD The inside view: Internal DTD subsets A single file processes faster than multiple files. Validity and well-formedness are kept in the same place.  You can use internal DTDs on a local system without connecting to the Internet Calling for outside support: Referencing external DTDs They’re recyclable They’re versatile They’re easy to change. They’re timesavers. Two are sometimes better than one Combining DTDs isn’t much different. Live by these two major rules when mixing these two types of DTDs: An XML processor always reads the internal subset first. Entities declared in the internal subset can be referenced in the external subset.

Mais conteúdo relacionado

Mais procurados (20)

XML and DTD
XML and DTDXML and DTD
XML and DTD
 
XML Introduction
XML IntroductionXML Introduction
XML Introduction
 
Session 1
Session 1Session 1
Session 1
 
XML
XMLXML
XML
 
Docbook
DocbookDocbook
Docbook
 
Document type definitions part 1
Document type definitions part 1Document type definitions part 1
Document type definitions part 1
 
Introduction to DTD
Introduction to DTDIntroduction to DTD
Introduction to DTD
 
Xml dtd
Xml dtdXml dtd
Xml dtd
 
DTD
DTDDTD
DTD
 
XML's validation - DTD
XML's validation - DTDXML's validation - DTD
XML's validation - DTD
 
Dtd
DtdDtd
Dtd
 
M.FLORENCE DAYANA WEB DESIGN -Unit 5 XML
M.FLORENCE DAYANA WEB DESIGN -Unit 5   XMLM.FLORENCE DAYANA WEB DESIGN -Unit 5   XML
M.FLORENCE DAYANA WEB DESIGN -Unit 5 XML
 
3 xml namespaces and xml schema
3   xml namespaces and xml schema3   xml namespaces and xml schema
3 xml namespaces and xml schema
 
XML, DTD & XSD Overview
XML, DTD & XSD OverviewXML, DTD & XSD Overview
XML, DTD & XSD Overview
 
XML Introduction
XML IntroductionXML Introduction
XML Introduction
 
4 xml namespaces and xml schema
4   xml namespaces and xml schema4   xml namespaces and xml schema
4 xml namespaces and xml schema
 
Session 2
Session 2Session 2
Session 2
 
XML Schema
XML SchemaXML Schema
XML Schema
 
DTD
DTDDTD
DTD
 
XML
XMLXML
XML
 

Semelhante a Xml For Dummies Chapter 8 Understanding And Using Dt Ds it-slideshares.blogspot.com

Semelhante a Xml For Dummies Chapter 8 Understanding And Using Dt Ds it-slideshares.blogspot.com (20)

Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
Web Services Part 1
Web Services Part 1Web Services Part 1
Web Services Part 1
 
O9xml
O9xmlO9xml
O9xml
 
Xml by Luqman
Xml by LuqmanXml by Luqman
Xml by Luqman
 
Xml
XmlXml
Xml
 
Xml 1
Xml 1Xml 1
Xml 1
 
CIS-189 Final Review
CIS-189 Final ReviewCIS-189 Final Review
CIS-189 Final Review
 
Unit 5 xml (1)
Unit 5   xml (1)Unit 5   xml (1)
Unit 5 xml (1)
 
Lotusphere 2006 AD212 Introduction to DXL
Lotusphere 2006 AD212 Introduction to DXLLotusphere 2006 AD212 Introduction to DXL
Lotusphere 2006 AD212 Introduction to DXL
 
About XML
About XMLAbout XML
About XML
 
XML Presentation-2
XML Presentation-2XML Presentation-2
XML Presentation-2
 
XML-Unit 1.ppt
XML-Unit 1.pptXML-Unit 1.ppt
XML-Unit 1.ppt
 
10. XML in DBMS
10. XML in DBMS10. XML in DBMS
10. XML in DBMS
 
Xml
XmlXml
Xml
 
Sgml and xml
Sgml and xmlSgml and xml
Sgml and xml
 
Xml and Co.
Xml and Co.Xml and Co.
Xml and Co.
 
What is xml
What is xmlWhat is xml
What is xml
 
Week1 xml
Week1 xmlWeek1 xml
Week1 xml
 
Intro to xml
Intro to xmlIntro to xml
Intro to xml
 
chapter 4 web authoring unit 4 xml.pptx
chapter 4 web authoring  unit 4 xml.pptxchapter 4 web authoring  unit 4 xml.pptx
chapter 4 web authoring unit 4 xml.pptx
 

Mais de phanleson

Learning spark ch01 - Introduction to Data Analysis with Spark
Learning spark ch01 - Introduction to Data Analysis with SparkLearning spark ch01 - Introduction to Data Analysis with Spark
Learning spark ch01 - Introduction to Data Analysis with Sparkphanleson
 
Firewall - Network Defense in Depth Firewalls
Firewall - Network Defense in Depth FirewallsFirewall - Network Defense in Depth Firewalls
Firewall - Network Defense in Depth Firewallsphanleson
 
Mobile Security - Wireless hacking
Mobile Security - Wireless hackingMobile Security - Wireless hacking
Mobile Security - Wireless hackingphanleson
 
Authentication in wireless - Security in Wireless Protocols
Authentication in wireless - Security in Wireless ProtocolsAuthentication in wireless - Security in Wireless Protocols
Authentication in wireless - Security in Wireless Protocolsphanleson
 
E-Commerce Security - Application attacks - Server Attacks
E-Commerce Security - Application attacks - Server AttacksE-Commerce Security - Application attacks - Server Attacks
E-Commerce Security - Application attacks - Server Attacksphanleson
 
Hacking web applications
Hacking web applicationsHacking web applications
Hacking web applicationsphanleson
 
HBase In Action - Chapter 04: HBase table design
HBase In Action - Chapter 04: HBase table designHBase In Action - Chapter 04: HBase table design
HBase In Action - Chapter 04: HBase table designphanleson
 
HBase In Action - Chapter 10 - Operations
HBase In Action - Chapter 10 - OperationsHBase In Action - Chapter 10 - Operations
HBase In Action - Chapter 10 - Operationsphanleson
 
Hbase in action - Chapter 09: Deploying HBase
Hbase in action - Chapter 09: Deploying HBaseHbase in action - Chapter 09: Deploying HBase
Hbase in action - Chapter 09: Deploying HBasephanleson
 
Learning spark ch11 - Machine Learning with MLlib
Learning spark ch11 - Machine Learning with MLlibLearning spark ch11 - Machine Learning with MLlib
Learning spark ch11 - Machine Learning with MLlibphanleson
 
Learning spark ch10 - Spark Streaming
Learning spark ch10 - Spark StreamingLearning spark ch10 - Spark Streaming
Learning spark ch10 - Spark Streamingphanleson
 
Learning spark ch09 - Spark SQL
Learning spark ch09 - Spark SQLLearning spark ch09 - Spark SQL
Learning spark ch09 - Spark SQLphanleson
 
Learning spark ch07 - Running on a Cluster
Learning spark ch07 - Running on a ClusterLearning spark ch07 - Running on a Cluster
Learning spark ch07 - Running on a Clusterphanleson
 
Learning spark ch06 - Advanced Spark Programming
Learning spark ch06 - Advanced Spark ProgrammingLearning spark ch06 - Advanced Spark Programming
Learning spark ch06 - Advanced Spark Programmingphanleson
 
Learning spark ch05 - Loading and Saving Your Data
Learning spark ch05 - Loading and Saving Your DataLearning spark ch05 - Loading and Saving Your Data
Learning spark ch05 - Loading and Saving Your Dataphanleson
 
Learning spark ch04 - Working with Key/Value Pairs
Learning spark ch04 - Working with Key/Value PairsLearning spark ch04 - Working with Key/Value Pairs
Learning spark ch04 - Working with Key/Value Pairsphanleson
 
Learning spark ch01 - Introduction to Data Analysis with Spark
Learning spark ch01 - Introduction to Data Analysis with SparkLearning spark ch01 - Introduction to Data Analysis with Spark
Learning spark ch01 - Introduction to Data Analysis with Sparkphanleson
 
Hướng Dẫn Đăng Ký LibertaGia - A guide and introduciton about Libertagia
Hướng Dẫn Đăng Ký LibertaGia - A guide and introduciton about LibertagiaHướng Dẫn Đăng Ký LibertaGia - A guide and introduciton about Libertagia
Hướng Dẫn Đăng Ký LibertaGia - A guide and introduciton about Libertagiaphanleson
 
Lecture 1 - Getting to know XML
Lecture 1 - Getting to know XMLLecture 1 - Getting to know XML
Lecture 1 - Getting to know XMLphanleson
 
Lecture 4 - Adding XTHML for the Web
Lecture  4 - Adding XTHML for the WebLecture  4 - Adding XTHML for the Web
Lecture 4 - Adding XTHML for the Webphanleson
 

Mais de phanleson (20)

Learning spark ch01 - Introduction to Data Analysis with Spark
Learning spark ch01 - Introduction to Data Analysis with SparkLearning spark ch01 - Introduction to Data Analysis with Spark
Learning spark ch01 - Introduction to Data Analysis with Spark
 
Firewall - Network Defense in Depth Firewalls
Firewall - Network Defense in Depth FirewallsFirewall - Network Defense in Depth Firewalls
Firewall - Network Defense in Depth Firewalls
 
Mobile Security - Wireless hacking
Mobile Security - Wireless hackingMobile Security - Wireless hacking
Mobile Security - Wireless hacking
 
Authentication in wireless - Security in Wireless Protocols
Authentication in wireless - Security in Wireless ProtocolsAuthentication in wireless - Security in Wireless Protocols
Authentication in wireless - Security in Wireless Protocols
 
E-Commerce Security - Application attacks - Server Attacks
E-Commerce Security - Application attacks - Server AttacksE-Commerce Security - Application attacks - Server Attacks
E-Commerce Security - Application attacks - Server Attacks
 
Hacking web applications
Hacking web applicationsHacking web applications
Hacking web applications
 
HBase In Action - Chapter 04: HBase table design
HBase In Action - Chapter 04: HBase table designHBase In Action - Chapter 04: HBase table design
HBase In Action - Chapter 04: HBase table design
 
HBase In Action - Chapter 10 - Operations
HBase In Action - Chapter 10 - OperationsHBase In Action - Chapter 10 - Operations
HBase In Action - Chapter 10 - Operations
 
Hbase in action - Chapter 09: Deploying HBase
Hbase in action - Chapter 09: Deploying HBaseHbase in action - Chapter 09: Deploying HBase
Hbase in action - Chapter 09: Deploying HBase
 
Learning spark ch11 - Machine Learning with MLlib
Learning spark ch11 - Machine Learning with MLlibLearning spark ch11 - Machine Learning with MLlib
Learning spark ch11 - Machine Learning with MLlib
 
Learning spark ch10 - Spark Streaming
Learning spark ch10 - Spark StreamingLearning spark ch10 - Spark Streaming
Learning spark ch10 - Spark Streaming
 
Learning spark ch09 - Spark SQL
Learning spark ch09 - Spark SQLLearning spark ch09 - Spark SQL
Learning spark ch09 - Spark SQL
 
Learning spark ch07 - Running on a Cluster
Learning spark ch07 - Running on a ClusterLearning spark ch07 - Running on a Cluster
Learning spark ch07 - Running on a Cluster
 
Learning spark ch06 - Advanced Spark Programming
Learning spark ch06 - Advanced Spark ProgrammingLearning spark ch06 - Advanced Spark Programming
Learning spark ch06 - Advanced Spark Programming
 
Learning spark ch05 - Loading and Saving Your Data
Learning spark ch05 - Loading and Saving Your DataLearning spark ch05 - Loading and Saving Your Data
Learning spark ch05 - Loading and Saving Your Data
 
Learning spark ch04 - Working with Key/Value Pairs
Learning spark ch04 - Working with Key/Value PairsLearning spark ch04 - Working with Key/Value Pairs
Learning spark ch04 - Working with Key/Value Pairs
 
Learning spark ch01 - Introduction to Data Analysis with Spark
Learning spark ch01 - Introduction to Data Analysis with SparkLearning spark ch01 - Introduction to Data Analysis with Spark
Learning spark ch01 - Introduction to Data Analysis with Spark
 
Hướng Dẫn Đăng Ký LibertaGia - A guide and introduciton about Libertagia
Hướng Dẫn Đăng Ký LibertaGia - A guide and introduciton about LibertagiaHướng Dẫn Đăng Ký LibertaGia - A guide and introduciton about Libertagia
Hướng Dẫn Đăng Ký LibertaGia - A guide and introduciton about Libertagia
 
Lecture 1 - Getting to know XML
Lecture 1 - Getting to know XMLLecture 1 - Getting to know XML
Lecture 1 - Getting to know XML
 
Lecture 4 - Adding XTHML for the Web
Lecture  4 - Adding XTHML for the WebLecture  4 - Adding XTHML for the Web
Lecture 4 - Adding XTHML for the Web
 

Último

Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 

Último (20)

Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 

Xml For Dummies Chapter 8 Understanding And Using Dt Ds it-slideshares.blogspot.com

  • 1. XML For Dummies Book Author : Lucinda Dykes & Ed Tittle Slides Prepared By: Son TN Chapter 8 :Understanding and Using DTDs
  • 2. Contents What ‘s a DTD ? Inspecting the XML Prolog Reading a DTD Using Element Declarations Declaring Attributes Understanding Notations Calling a DTD
  • 3. 8. 1. What’s a DTD ? Document Type Definition (DTD) Defines the syntax, grammar & semantics Defines the document structure What Elements, Attributes, Entities, etc are permitted? How are the document elements related & structured? Referenced by or defined in XML documents, but it’s not XML! Enables validation of XML documents using an XML Parser. Can be referenced to by more than one XML document. DTD’s may reference other DTD’s
  • 4. 1. What’s a DTD ? (Cont) Table 8-1 deciphers some of the terms
  • 5. 8.1.1 When to use a DTD XML doesn’t require you to use a DTD Including DTDs in a document is to decide whether you want to jump off that particular bridge. Several reasons to use DTD: To create and manage large sets of documents for your company. To define clearly what markup may be used in certain documents and how markup should be sequenced. To provide a common frame of reference for documents that many users can share. Standardization and control are what they’re all about!
  • 6. 8.1.2 When NOT to use a DTD You may not need to use a DTD if: You’re working with only one or a few small documents. You’re using a nonvalidating processor to handle your XML documents. Let the XML documents or data that you work with drive you toward or away from creating formal document descriptions.
  • 7. 8.2 2. Inspecting the XML Prolog The XML prolog is the first thing that a processor — or human eye, for that matter — sees in an XML document An XML prolog may include the following items XML declaration DOCTYPE declaration Comments Processing instructions White space The XML declaration.
  • 8. 8.2.1 Examining the XML declaration A declaration is markup that tells an XML processor what to do. Declarations don’t add structure or define document elements. They provide instructions for a processor, such as what type of document to process and what standards to use. The XML declaration can include version, encoding, and/or standalone attributes: This is an XML document. The version of XML is XML 1.0. The character encoding is UTF-8. An external document may be needed to complete the document content (standalone=”no”). <?xml version=”1.0” encoding=”UTF-8” standalone=”no”?>
  • 9. 8.2.2 Discovering the DOCTYPE The document type (DOCTYPE) declaration is markup that tells the processor where it can find a specific DTD. Here’s the basic markup of a DOCTYPE declaration: <!DOCTYPE marks the start of the DOCTYPE declaration. Books is the name of the DTD used. SYSTEM “bookstore.dtd” tells the processor to fetch an external document — in this case, a file named bookstore.dtd. <!DOCTYPE books SYSTEM “bookstore.dtd”>
  • 10. 8.2.3 Understanding comments Comments — use them and read them! Use comments to include text that explains a document better (humans love that sort of thing) without that text being displayed — or even processed. The correct format is: You have two rules to live by when you’re using comments: Never nest a comment inside another element. Never include - (hyphen) or -- (double hyphen) within the comment text. Using comments enables you to leave human-style instructions (that is, comments) addressed to someone who reads the markup without disrupting the document’s structure. <!-- comment text --> <!-- Include your comment here -->
  • 11. 8.2.4 Processing instructions Processing instructions are like comments addressed to machines; they provide a way to send instructions to computer programs or applications. All processing instructions follow this format: A common example of a processing instruction in XML documents is a reference to stylesheets. All processing instructions must begin with <? and end with ?>. <?name data?> <?xml:stylesheet type=”text/css” href=”bookstore.css”?>
  • 12. 8.2.5 How about that white space? XML considers four characters to be whitespace: the carriage return ( or ch(13)), the linefeed ( or ch(10)), the tab(), and the spacebar (' '). In XML documents, there are two types of whitespace: Significant whitespace is part of the document content and should be preserved. Insignificant whitespace is used when editing XML documents for readability. The XML specification allows you to add white space outside markup; it’s ignored when the document is processed When you write markup, consider adding a line of white space between sections.
  • 13.
  • 14.
  • 15. 8. 4.1 Using the EMPTY element type… Empty elements are like boxes you put in place but want left empty. To use them, first you have to point them out to the processor — by declaring them. Such a declaration looks like this: In our example DTD, the source element is an empty element: If (on the other hand) you want your element to serve as a catch-all box that you can put anything in, you may want to use another type of content specification: ANY. <!ELEMENT Name EMPTY> <!ELEMENT source EMPTY>
  • 16.
  • 17. Allow an element to contain both text and other elements (In that case, don’t forget the asterisk!<!ELEMENT Name (#PCDATA | Child1 | Child2)*> <!ELEMENT Name #PCDATA> <!ELEMENT author (#PCDATA | publisher )*>
  • 18. 8. 4.3 Using element content models An element content model describes the child elements that an element can contain. The basic structure is : Example The element content model uses occurrence indicators to control the order and number of times that elements can occur. <!ELEMENT Name (childName)> <!ELEMENT books (book+)> <!ELEMENT customer (custNumber, lastName, firstName, address, city, state, zip, phone, email)>
  • 19. 8. 4.4 Declaring Attributes You need to include attribute-list declarations in your DTD whenever you want elements to use associated attributes. The attribute-list declaration lists all attributes that may be used within a given element and also defines each attribute’s type and default value. The basic format for an attribute-list declaration is: Example The following list defines the terms that appear in attribute-list declarations: Element name Attribute name Datatype (CDATA, or character data , ID, IDREF, IDREFS, ENTITY, ENTITIES , NMTOKEN, NMTOKENS, NOTATION, Enumrated list Default value (#REQUIRED, #IMPLIED , #FIXED , value) <!ATTLIST element-name attribute-name datatypedefaultvalue> <!ATTLIST customer custType CDATA #REQUIRED> <!ATTLIST price priceType (Retail | Wholesale) #REQUIRED>
  • 20. 8. 4.5 Discovering Entities An entity declaration defines an alias for a block of text. You can attach a name to a specific block of text and then insert the whole block by using just one name. An entity declaration in a DTD looks like this: entityNameis the name of the entity and is used to call up the replacement Text in your document. The two main classifications of entities are general entities and parameter entities. A general entity is an abbreviation for data that becomes part of the content of an XML document. A parameter entity is an abbreviation for data that becomes part of the content of a DTD. <!ENTITY entityName“replacementText”>
  • 21. 8. 4.6 General entities The XML specification supports two types of general entities: Internal entities hold their values in the entity declaration external entities point to an external file. Internal entities To declare a general internal entity, you must use the following syntax: Or <!ENTITY entityName“replacementText”> <!ENTITY store1 “River Valley Center”> Five commonly used internal entities are already defined as part of XML
  • 22. 8. 4.6 General entities (cont) External entities External entities help you integrate external documents and files into your XML document. In general, you use them in one of two ways: As a mechanism to divide your document into logical pieces. To reference images, multimedia clips, and other non-XML files. To declare an external entity, you use the following syntax: Use the following syntax to refer to a public identifier not stored on your system The benefit of using external entities is that they’re reusable. They are subject to three important limitations: You can’t use an entity before you define it. Your entity references have to do something. The entity has to refer to data that’s in the XML document. <!ENTITY entityNameSYSTEM “system-identifier”> <!ENTITY entityNamePUBLIC “system-identifier”>
  • 23. 8. 4.7 Parameter entities A parameter entity Is an entity that is created specifically for the purpose of helping you use shortcuts when you write a DTD. They don’t refer to content in XML documents at all. Parameter entities may also be internal or external. Internal entities : Internal parameter entities work well to eliminate the need to repeat commonly used element and attribute declarations. Parameter entities must be declared before they can be used. The general syntax for an internal parameter entity declaration: External entities : Use external parameter entities to carve DTDs into bite-size bits of declarations that are easy to read and manipulate. You can then save each bit in a separate file and create a single parameter entity in the master DTD that points to each individual file. <!ENTITY % entityName “replacementText”>
  • 24. 8. 4.7 Parameter entities External entities : These kinds of parameter entities are called external parameter entity references because they refer to information that’s external to the DTD in which they appear. <-- Master DTD for book information, sales data, and customer information --> <!ENTITY % Bks SYSTEM “book.dtd”> <!ENTITY % Sls SYSTEM “sales.dtd”> <!ENTITY % Cust SYSTEM “customer.dtd”> %Bks; %Sls; %Cust;
  • 25. 8. 5. Understanding Notations In XML, you may come across data that you would like to include in your documents that is not XML. Notations allow you to include that data in your documents by describing the format it and allowing your application to recognize and handle it. The format for a notation is: The name identifies the format used in the document, and the external_id identifies the notation - usually with MIME-types. For example, to include a GIF image in your XML document: You can also use a "public" identifier, instead of "system". <!NOTATION name system "external_ID"> <!NOTATION GIF system "image/gif"> <!NOTATION GIF public  "-//IETF/NOSGML Media Type image/gif//EN"  "http://www.isi.edu/in-notes/iana/assignments/media-types/image/gif">
  • 26. 8. 5. Calling a DTD DTDs come in two flavors: internal and external. Internal DTDs are entirely contained in the XML prolog of an XML document. External DTDs are contained in an external file and are referenced in the DOCTYPE declaration of an XML document.
  • 27. 8. 5.1 Internal DTDs If your DTD is short and simple, and you don’t need to include it in a large group of XML documents, you may want to use it as an internal DTD. To add an internal DTD to your XML document, you include it within the DOCTYPE declaration Example <!DOCTYPE rootElement [ ... the entire DTD goes here ... ] <?xml version=”1.0” encoding=”UTF-8”?> <!DOCTYPE books [ <!ELEMENT books (book+, totalCost, customer)> <!ELEMENT book (bookInfo, salesInfo)> ... ] <books> <book contentType=”Fiction” format=”Hardback”> <bookInfo> ...
  • 28. 8. 5.2 External DTDs Using external DTDs is a great idea, because you can then share a single DTD among any group of XML documents. To use an external DTD with an XML document, simply reference the external DTD in the DOCTYPE declaration in the XML prolog of your XML document. Example <!DOCTYPE rootElement SYSTEM dtd.url> <?xml version=”1.0” encoding=”UTF-8” standalone=”no”?> <!DOCTYPE books SYSTEM “bookstore.dtd”> <books> ...
  • 29. 8. 5.3 When to use an internal or external DTD The inside view: Internal DTD subsets A single file processes faster than multiple files. Validity and well-formedness are kept in the same place. You can use internal DTDs on a local system without connecting to the Internet Calling for outside support: Referencing external DTDs They’re recyclable They’re versatile They’re easy to change. They’re timesavers. Two are sometimes better than one Combining DTDs isn’t much different. Live by these two major rules when mixing these two types of DTDs: An XML processor always reads the internal subset first. Entities declared in the internal subset can be referenced in the external subset.
  • 30. 8.6 Summary Defining DTDs Knowing when and why to use a DTD Using an XML prolog Exploring an XML DTD Declaring elements and their attributes Declaring an entity Noting notations Including internal and external DTDs Choosing between internal and external DTDs