SlideShare a Scribd company logo
Elements and AttributesCIS-189
Complies with rules Rules allow easy transfer and read of data independent of platform, applicationA Parserreads XML fileParsers typically run as a service to another applicationA file that doesn’t comply with rules has afatal error,and the parsercannot continueBy definition, a file that isn’t well formed has a fatal errorAny violation of rules is an errorWell-Formed XML
Start tag must have an end tag or be self-closingTags cannot overlapMust have one – and only one – root elementElement names obey naming rulesXML is case-sensitiveWhitespace is maintained in PCDATAWhitespace isn’t stripped out or ignored“PCDATA” = plain character data or parsed character dataWell Formed XML
An element begins with start tag and includes everything through end tagName is an element:<name>Dave</name>Person is an element:<person><name>Dave</name></person>Elements Revisited
Element name can include a space after the nameElement cannot have a space at beginning of start tagElement name must begin with letters or dashAfter the first character, numbers, hyphens, periods are acceptableCannot use spaces or: (colon) in namesColon is reserved for special usesXML cannot be used as the first 3 letters of a name (Upper, lower or mixed case)Naming Elements
CDATA refers to character dataValues that are treated as those charactersPCDATA refers to parsed character dataValues that are translated for a specific meaning or purposeWhitespace is treated differently than HTMLMaintainedCarriage return and linefeed characters are both treated as single linefeed by parserWorking with Data
Provide another way to represent valuesDefined within the start tag of an elementWork in a name/value pairMust include both a name and value for a valid statement (an empty string is a valid value)Value must be enclosed in single or double quotesOpening quote must be same as closing (can’t pair a single quote and double quote)Be consistent for ease of coding, reading, and maintenance, using all single or all double quotesAttributes
Attribute names must conform to same rules as element namesStart with letter or dashCan use numbers, hyphens, periods after the first characterName of each attribute must be unique within an elementAttribute Names
<person id=“1”>	<firstname>Dave</firstname>	<lastname suffix=“Jr.”>Smith</lastname></person>Sample Attributes
Elements can be more complexCan include child elements if neededAttributes are about a single valueAttributes can simplify logicCan avoid or reduce nestingCan simplify logicChoice of element or attribute most often simply a design choice, preferenceUsing Attributes and Elements
Comments are used to documentSimilar to HTML <!-- this is a comment -->Comments cannot exist within a tagInclude comments in your codeName, assignment/exercise, dateDescription of structure, logic, referencesComments
Provide information to aid the processing of the file<? XML version=“1.0”?>If include XML declaration must be first entryCannot have any character preceding the open tagIf include XML declaration must have at least the versionHave versions 1.0, 1.1XML Declarations
Optional settings are encoding, standaloneEncoding specifies which character set is being used (how characters are represented)Standalone tells the parser if document is complete by itself, or relies on another fileOptional XML Declarations
Processing instructions are for consuming applicationNot used by XML parserIncludes information/commands that application needs to complete some task	<? Statement ?>Processing Instructions
Some symbols have special meaningLess than (<)Greater than (>)Ampersand (&)Cannot use these characters directly unless wrapped in a CDATA sectionIf need single symbol can substitute&lt for <, &gt for >, &amp for & Special Characters

More Related Content

PPT
PPTX
PPT
Ch2 neworder
PPT
Xml Presentation-3
PPTX
Intro xml
PDF
XML
Ch2 neworder
Xml Presentation-3
Intro xml
XML

What's hot (20)

PPTX
Extensible Markup Language (XML)
PPT
XML Presentation-2
PPTX
XML | Computer Science
PPT
02 well formed and valid documents
PPT
Intro to xml
PPTX
Sgml and xml
PPTX
PPT
Xml Presentation-1
PPT
EXtensible Markup Language
PDF
Python xml processing
PDF
Xml tutorial
 
PDF
Xml
PPTX
Xml basics
PPT
XML Schema
PDF
SQL Server - Querying and Managing XML Data
PPT
10. XML in DBMS
PDF
XML and Localization
PDF
M.FLORENCE DAYANA WEB DESIGN -Unit 5 XML
Extensible Markup Language (XML)
XML Presentation-2
XML | Computer Science
02 well formed and valid documents
Intro to xml
Sgml and xml
Xml Presentation-1
EXtensible Markup Language
Python xml processing
Xml tutorial
 
Xml
Xml basics
XML Schema
SQL Server - Querying and Managing XML Data
10. XML in DBMS
XML and Localization
M.FLORENCE DAYANA WEB DESIGN -Unit 5 XML
Ad

Similar to Well Formed XML (20)

PPTX
Document type definitions part 1
PPT
2 dtd - validating xml documents
PPTX
PPTX
XPath Introduction
PPT
Xml by Luqman
PPT
Xml and Co.
PPTX
Xml For Dummies Chapter 8 Understanding And Using Dt Ds it-slideshares.blog...
PPT
PPTX
chapter 4 web authoring unit 4 xml.pptx
PPT
Chen's first test slides
PPT
Chen test paper20abcdeftfdfd
PPT
Test for an issue
PPT
Relax NG, a Schema Language for XML
PPT
Introduction to XML
PPT
Data mining lecture 3 taught at Stanford
PDF
xml introduction in web technologies subject
PPTX
Unit 5 xml (1)
Document type definitions part 1
2 dtd - validating xml documents
XPath Introduction
Xml by Luqman
Xml and Co.
Xml For Dummies Chapter 8 Understanding And Using Dt Ds it-slideshares.blog...
chapter 4 web authoring unit 4 xml.pptx
Chen's first test slides
Chen test paper20abcdeftfdfd
Test for an issue
Relax NG, a Schema Language for XML
Introduction to XML
Data mining lecture 3 taught at Stanford
xml introduction in web technologies subject
Unit 5 xml (1)
Ad

More from Randy Riness @ South Puget Sound Community College (20)

Recently uploaded (20)

PPTX
GDM (1) (1).pptx small presentation for students
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PDF
01-Introduction-to-Information-Management.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Pharma ospi slides which help in ospi learning
PDF
Computing-Curriculum for Schools in Ghana
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
Institutional Correction lecture only . . .
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PDF
RMMM.pdf make it easy to upload and study
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
GDM (1) (1).pptx small presentation for students
Final Presentation General Medicine 03-08-2024.pptx
Abdominal Access Techniques with Prof. Dr. R K Mishra
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
01-Introduction-to-Information-Management.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Pharma ospi slides which help in ospi learning
Computing-Curriculum for Schools in Ghana
102 student loan defaulters named and shamed – Is someone you know on the list?
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Institutional Correction lecture only . . .
Supply Chain Operations Speaking Notes -ICLT Program
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
RMMM.pdf make it easy to upload and study
202450812 BayCHI UCSC-SV 20250812 v17.pptx
O7-L3 Supply Chain Operations - ICLT Program
Chinmaya Tiranga quiz Grand Finale.pdf

Well Formed XML

  • 2. Complies with rules Rules allow easy transfer and read of data independent of platform, applicationA Parserreads XML fileParsers typically run as a service to another applicationA file that doesn’t comply with rules has afatal error,and the parsercannot continueBy definition, a file that isn’t well formed has a fatal errorAny violation of rules is an errorWell-Formed XML
  • 3. Start tag must have an end tag or be self-closingTags cannot overlapMust have one – and only one – root elementElement names obey naming rulesXML is case-sensitiveWhitespace is maintained in PCDATAWhitespace isn’t stripped out or ignored“PCDATA” = plain character data or parsed character dataWell Formed XML
  • 4. An element begins with start tag and includes everything through end tagName is an element:<name>Dave</name>Person is an element:<person><name>Dave</name></person>Elements Revisited
  • 5. Element name can include a space after the nameElement cannot have a space at beginning of start tagElement name must begin with letters or dashAfter the first character, numbers, hyphens, periods are acceptableCannot use spaces or: (colon) in namesColon is reserved for special usesXML cannot be used as the first 3 letters of a name (Upper, lower or mixed case)Naming Elements
  • 6. CDATA refers to character dataValues that are treated as those charactersPCDATA refers to parsed character dataValues that are translated for a specific meaning or purposeWhitespace is treated differently than HTMLMaintainedCarriage return and linefeed characters are both treated as single linefeed by parserWorking with Data
  • 7. Provide another way to represent valuesDefined within the start tag of an elementWork in a name/value pairMust include both a name and value for a valid statement (an empty string is a valid value)Value must be enclosed in single or double quotesOpening quote must be same as closing (can’t pair a single quote and double quote)Be consistent for ease of coding, reading, and maintenance, using all single or all double quotesAttributes
  • 8. Attribute names must conform to same rules as element namesStart with letter or dashCan use numbers, hyphens, periods after the first characterName of each attribute must be unique within an elementAttribute Names
  • 10. Elements can be more complexCan include child elements if neededAttributes are about a single valueAttributes can simplify logicCan avoid or reduce nestingCan simplify logicChoice of element or attribute most often simply a design choice, preferenceUsing Attributes and Elements
  • 11. Comments are used to documentSimilar to HTML <!-- this is a comment -->Comments cannot exist within a tagInclude comments in your codeName, assignment/exercise, dateDescription of structure, logic, referencesComments
  • 12. Provide information to aid the processing of the file<? XML version=“1.0”?>If include XML declaration must be first entryCannot have any character preceding the open tagIf include XML declaration must have at least the versionHave versions 1.0, 1.1XML Declarations
  • 13. Optional settings are encoding, standaloneEncoding specifies which character set is being used (how characters are represented)Standalone tells the parser if document is complete by itself, or relies on another fileOptional XML Declarations
  • 14. Processing instructions are for consuming applicationNot used by XML parserIncludes information/commands that application needs to complete some task <? Statement ?>Processing Instructions
  • 15. Some symbols have special meaningLess than (<)Greater than (>)Ampersand (&)Cannot use these characters directly unless wrapped in a CDATA sectionIf need single symbol can substitute&lt for <, &gt for >, &amp for & Special Characters