首页 > 程序开发 > 软件开发 > 其他 >

The Object-Oriented Thought Process

2018-05-15

XML providesstandards to move data in a variety of ways Often we can think of data asmoving vertically and horizontally The term vertical means that data is meant to move through multipleindustry groups

11 Objects and Portable Data: XML

XML is astandard mechanism for defining and transporting data between potentially

disparate systems.

Portable Data

XML providesstandards to move data in a variety of ways. Often we can think of data asmoving vertically and horizontally.The term vertical means that data is meant to move through multipleindustry groups. Horizontalapplications are specific to a particular industry, such as retail ortransportation.

\

Figure 11.1 XML across industries.

Hospitality

英 [hsptlti] 美 [hɑsptlti]

n. 殷勤好客;招待,款待;(气候,环境等的)宜人,适宜

The Extensible Markup Language (XML)

HTML (HypertextMarkup Language).

Both XML andHTML are descendants of SGML, the Standard Generalized Markup Language.

XML is notproprietary and the World Wide Web Consortium (W3C) is the organization thatproposes recommendations and that promotes the distribution of its standards.

XML Versus HTML

HTML presentsdata, and XML describes the data.

Document Type Definition (DTD)

The DTD is where you define the tagsthat describe your data.

Valid Document

You are not required to use a DTD.However, using a DTD provides a great benefit to validating XML documents.

For example, ifyou are creating a purchase order system, you might want to create a tag calledseorder> in the DTD. If you then misspell the tag like this:

,this problem will be detected, and the document will be flagged as invalid.

XML and Object-Oriented Languages

Alpha Company, adepartment store, uses an Oracle database, and Beta Company, a vacuum machinemanufacturer, uses a SQL Server database.Alpha Company wants to purchase somevacuum cleaners from Beta Company for its inventory.

Proprietary Solutions

Alpha Company can create an XML specification to which all its supplierscan connect.

\

Figure 11.2 Application-to-application data transfer.

Sharing Data Between Two Companies

\

Validating the Document with the Document Type Definition(DTD)

supplier.dtd

The first line is an XMLcomment.

This tag defines an element called supplier.

The element is then defined to be a data elementdesignated by

#PCDATA.

PCDATA

PCDATA stands for ParsedCharacter Data and is simply standard character information

parsedfrom the text file.

Integrated the DTD into the XML Document

supplier.xml

The BetaCompany

12000 OntarioSt

Cleveland

OH

24388

XML Notepad

XML Notepad can help usunderstand the structure of an XML document.

Using Cascading Style Sheet

supplier.css

companyname{font-family:Arial, sans-serif;

font-size:24;

color:blue;

display:block;}

street {font-family:±Times New Roman±,serif;

font-size:12;

color:red;

display:block;}

city {font-family:±Courier New±, serif;

font-size:18;

color:black;

display:block;}

state {font-family:±Tahoma±; serif;

font-size:16;

color:gray;

display:block;}

zip {font-family:±Arial Black±,sans-serif;

font-size:6;

color:green;

display:block;}

\

Figure 11.11 The XML document using a cascading stylesheet.

Conclusion

In thischapter,we discussed many aspects of XML and why it is a very importanttechnology within the IT community

相关文章
最新文章
热点推荐