0% found this document useful (0 votes)
24 views12 pages

Chapter 11

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views12 pages

Chapter 11

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

The Object-Oriented

Thought Process
Chapter 11

Objects and Portable Data: XML and JSON


Portability

Although portable languages are powerful tools,


they are really only half of the application
development equation.
– The programs that are written using these
languages must process data, and this data
must be turned into information.
– Information is the other half of the
portability equation.
Portable Data

XML provides standards to move data in a variety


of ways.
– Often we can think of data as moving
vertically and horizontally.
• The term vertical means that data is meant to
move through multiple industry groups.
• Horizontal applications are specific to a
particular industry, such as retail or
transportation.
The Extensible Markup Language
(XML)
The primary function of HTML is to present data
in a browser.
– XML, on the other hand, does concern itself
with data verification issues.
– XML is much more strict with its format
than HTML and was designed to represent
data.
XML Versus HTML

HTML tags are all predefined. Tags such as


<HTML>, <HEAD>, <BODY>, and so on are
all defined in the HTML specification.
– You cannot add your own tags.
• Because HTML is intended for formatting
purposes, this is not a problem.
– XML, however, is meant to define data.
• To define data, you need to create your own tag
names.
XML and Object-Oriented
Languages
XML works hand-in-hand with object-oriented
languages to provide what I have termed
“portable information.”
– Often, an application written in an object-
oriented language is developed to interact
with XML.
– The goal is to share data in a pre-
determined, portable manner.
Parsers

A parser is an application that reads a document


and extracts specific information.
– The parser reads each line of a program
and uses specific grammar rules to
determine how to produce code.
– A parser would verify that a print statement
was written with the appropriate syntax.
Validating the Document (DTD)

To define data, you need to create your own tag


names.
– This is where a document called the
Document Type Definition (DTD) comes
into play. The DTD is where you define the
tags that describe your data.
• You are not required to use a DTD.
However, using a DTD provides a great
benefit to validating XML documents.
Integrating the DTD into the XML
Document
XML Validation

Many applications will validate XML code.


– The XML validator at the w3schools site is
one that is easily accessible.

http://www.w3schools.com/xml/xml_validator.asp
Using Cascading Style Sheets

Although XML is not generally used for


presentation purposes, there are ways to
format XML.
– One of these is to use CSS. CSS are used
heavily in the HTML world to format
content.
– To a certain degree, CSS can be used to
format XML.
JavaScript Object Notation
(JSON)
Although XML is much more structured,
especially when using a DTD, technologies
such as the JavaScript Object Notation, or
JSON, fall into the category of “more flexible.”
– The w3schools site provides the following
bullet item description of JSON as:
1. lightweight text-data interchange format
2. language independent
3. “self-describing” and easy to understand

You might also like