XML/Introduzione: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Nessun oggetto della modifica
Riga 91:
</blockquote>
 
= XML =
The purpose of eXtensible Markup Language (XML) is to make information self-describing. Based on SGML, XML is designed to support electronic commerce. The definition of XML, completed in early 1998 by the [http://www.w3.org/ World Wide Web Consortium (W3C)], is a meta language—a language to generate languages. XML should steadily replace HTML on many Web sites because of some key advantages. The major differences between XML and HTML are captured in the following table.
 
Many computer systems contain data in incompatible formats. A time-consuming challenge is to exchange data between such systems. XML is a generic data storage format that comes bundled with a number of tools and technologies that should make it easier to exchange specific XML 'applications' between incompatible systems. Since XML is open and generic, it is expected that as time progresses, more and more organisations and people will jump onto the XML bandwagon, both developers and data users. This should make XML the ultimate viable technology for certain types of data exchange.
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td>'''XML'''</td>
<td>'''HTML'''</td>
</tr>
<tr>
<td>Information content</td>
<td>Information presentation</td>
</tr>
<tr>
<td>Extendable set of tags</td>
<td>Fixed set of tags</td>
</tr>
<tr>
<td>Data exchange language</td>
<td>Data presentation language</td>
</tr>
<tr>
<td>Greater hypertext linking</td>
<td>Limited hypertext linking</td>
</tr>
</table>
 
XML is not only used for the exchange of information, but it can also be used for the publication of Web pages. XML has a very strict syntax and allows for Web browsers to be smaller and faster and as such is well suited for use with Personal Digital Assistant (PDAs) and cellphones. Web browsers that interpret HTML documents, on the other hand, are bloated with programming code to compensate for HTML’s not so strict coding.
The eXtensible in XML means that a new data exchange language can be created by defining its structure and tags. For example, the [http://www.opengis.org/ OpenGIS Consortium] designed a Geographic Markup Language (GML) to facilitate the electronic exchange of geographic information. Similarly, the [http://www.opentourism.org Open Tourism Consortium] is working on the definition of TourML to support exchange of tourism information. Another good example of XML in action is [http://www.newsml.org NewsML™].
 
The types of data generally well suited for encoding as XML are those where field lengths are unknown and unpredictable and where field contents are predominantly of a textual nature.
 
 
An XML schema allows for the exchange of information in a standardized structure. A schema defines custom markup tags that can contain attributes to describe the content that is enclosed by these tags. Information from the tagged data in the XML document can be extracted using an application called a “parser” and with the use of an XML stylesheet the data can be formatted for a Web page.
 
XML's power lies in the combination of custom markup tags and content in a defined XML document. The purpose of eXtensible Markup Language (XML) is to make information self-describing. Based on SGML, XML is designed to support electronic commerce. The definition of XML, completed in early 1998 by the [http://www.w3.org/ World Wide Web Consortium (W3C)], is a meta language—a language to generate languages. XML should steadily replace HTML on many Web sites because of some key advantages. The major differences between XML and HTML are captured in the following table.
 
'''Exhibit 4: XML vs HTML'''
 
{| width="100%" border="1" cellspacing="0" cellpadding="0"
|-
| '''XML'''
| '''HTML'''
|-
| Information content
| Information presentation
|-
| Extendable set of tags
| Fixed set of tags
|-
| Data exchange language
| Data presentation language
|-
| Greater hypertext linking
| Limited hypertext linking
|}
 
 
The eXtensible in XML means that a new data exchange language can be created by defining its structure and tags. For example, the [http://www.opengis.org/ OpenGIS Consortium] designed a Geographic Markup Language (GML) to facilitate the electronic exchange of geographic information. Similarly, the [http://www.opentourism.org Open Tourism Consortium] is working on the definition of TourML to support exchange of tourism information. Another good example of XML in action is [http://www.newsml.org NewsML&trade;].
 
In this text, we will cover all the features of XML, but at this point let us introduce a few of the key features.
 
== Key features of XML ==
* Elements have both an opening and a closing tag
* Elements follow a strict hierarchy with only one root element
Line 134 ⟶ 142:
* '''Faster and more precise Web searching:''' When the meaning of information can be determined by a computer (by reading the tags), Web searching will be enhanced. For example, if you are looking for a specific book title, it is far more efficient for a computer to search for text between the pair of tags <booktitle> and </booktitle> than search an entire file looking for the title. Furthermore, spurious results should be eliminated.
 
== The major XML elements ==
 
The major XML elements are:
* '''XML schemadocument''': An XML file containing XML code.
* '''XML schema''': A schema is an XML file that describes the structure of a document and its tags.
* '''XML file:stylesheet''': AnA XML filestylesheet is aan fileXML containing formatting instructions for an XML codefile.
* '''XML stylesheet:''' A stylesheet is an XML containing formatting instructions for an XML file.
In the next few chapters, you will learn how to create and use each of these elements of XML.
 
== XML at United Parcel Service (UPS) ==
<blockquote style="background: lightyellow; border: 1px solid black; padding: 1em;">
<table width="100%" border="1" >
“UPS is a service company and it is all about scale and speed,” says Geoff Chalmers, Project Leader at UPS eSolutions Department. In 2003, UPS had $33.5 billion annual revenue and 357,000 employees worldwide. Six percent of the United States Gross Domestic Product (GDP) on any given day is in UPS’ system.<br/></br>
<tr style="horizontal-align:wraptext;">
<td style="background-color:lightyellow" >
“UPS is a service company and it is all about scale and speed.” says Geoff Chalmers, Project Leader at UPS eSolutions Department. In 2003, UPS had $33.5 billion annual revenue and 357,000 employees worldwide. Six percent of the United States Gross Domestic Product (GDP) on any given day is in UPS’ system.
<br/><br/>
UPS uses technology extensively. The Information Systems department employs 4,000 people. The Company Web site has 166 different country home pages and is supported by 44 applications.
<br/><br/>
UPS delivers around 13 million packages everyday, and customers can track these shipments via the UPS Web site, which receives around 200 million hits daily. Nineteen of the applications within ups.com are XML OnLine Tool (Web services) applications.
<br/><br/>
UPS’s online tools are developed specifically to be integrated with customers’ applications. This makes the customer’s task simpler, easier, and faster. UPS verified the importance of simplicity and speed, via ‘CampusShip’, a product that has been one of the UPS’s most successful in the last 10 years. UPS CampusShip® is a Web-based, UPS-hosted shipping system. Using an Internet connection, employees can ship their own packages and letters from any desktop, while management maintains overall control of shipping activities. UPS CampusShip® allows simultaneous shipper autonomy and managerial cost-control within the organization. This product has been successful because no installation or software maintenance is required and it is quick to implement. XML Online Tools enabled cheap and fast evolution of the CampusShip®.
 
UPS uses technology extensively. The Information Systems department employs 4,000 people. The Company Web site has 166 different country home pages and is supported by 44 applications.<br/></br>
<br/><br/>
UPS favors XML especially because it is agnostic; platform and language independent. These features make XML very flexible and powerful. It is also decoupled and scalable. XML has enabled UPS to target a broader market and reduce customer interaction, and thus the cost of customer service. Another positive feature of XML is that it is backward compatible. The adoption of XML has reduced maintenance, implementation, and usage costs significantly within UPS.
<br/><br/>
However these advantages don’t come without a price. “XML is inefficient in so many ways” says Geoff Chalmers. XML unfortunately takes more CPU and bandwidth than the other technologies. Yet bandwidth and CPU are cheap and getting cheaper everyday, so this is a gradually disappearing problem.
<br/><br/>
Nevertheless, Geoff Chalmers also thinks that XML doesn’t work well in databases. He says that it is too wordy and it is an exchange medium rather than a database medium. There were some early attempts to tightly integrate XML and databases. Because databases do supply structure and identification to data as does XML, the value-add of XML-database integration is limited to applying hierarchical structure. On the other hand, if data is to be stored as a blob, then XML makes sense. Another problem that he points out about XML is that business rules cannot be expressed in XML schemas.
<br/><br/>
Finally, raw XML programming and debugging can be challenging. Therefore, UPS’s enterprise customers are starting to explore the code generators and embedded facilities to be found in .Net and BEA. However hand coding by experienced in-house engineers is a must for the high availability, scalability, and performance that UPS requires for the UPS OnLine Tools.
 
UPS delivers around 13 million packages everyday, and customers can track these shipments via the UPS Web site, which receives around 200 million hits daily. Nineteen of the applications within ups.com are XML OnLine Tool (Web services) applications. <br/></br>
 
UPS’s online tools are developed specifically to be integrated with customers’ applications. This makes the customer’s task simpler, easier, and faster. UPS verified the importance of simplicity and speed, via ‘CampusShip’, a product that has been one of the UPS’s most successful in the last 10 years. UPS CampusShip® is a Web-based, UPS-hosted shipping system. Using an Internet connection, employees can ship their own packages and letters from any desktop, while management maintains overall control of shipping activities. UPS CampusShip® allows simultaneous shipper autonomy and managerial cost-control within the organization. This product has been successful because no installation or software maintenance is required and it is quick to implement. XML Online Tools enabled cheap and fast evolution of the CampusShip®.<br/></br>
 
UPS favors XML especially because it is agnostic; platform and language independent. These features make XML very flexible and powerful. It is also decoupled and scalable. XML has enabled UPS to target a broader market and reduce customer interaction, and thus the cost of customer service. Another positive feature of XML is that it is backward compatible. The adoption of XML has reduced maintenance, implementation, and usage costs significantly within UPS.<br/></br>
</td></tr></table>
 
However these advantages don’t come without a price. “XML is inefficient in so many ways” says Geoff Chalmers. XML unfortunately takes more CPU and bandwidth than the other technologies. Yet bandwidth and CPU are cheap and getting cheaper everyday, so this is a gradually disappearing problem.<br/></br>
<table width="100%" border="1" bgcolor="lightgreen">
<tr>
<td><b>
Section summary: XML is a convertible meta language which supports the electronic commerce by sticking to certain rules.
</b></td>
</tr>
</table>
 
Nevertheless, Geoff Chalmers also thinks that XML doesn’t work well in databases. He says that it is too wordy and it is an exchange medium rather than a database medium. There were some early attempts to tightly integrate XML and databases. Because databases do supply structure and identification to data as does XML, the value-add of XML-database integration is limited to applying hierarchical structure. On the other hand, if data is to be stored as a blob, then XML makes sense. Another problem that he points out about XML is that business rules cannot be expressed in XML schemas.<br/></br>
</td></tr></table>
 
Finally, raw XML programming and debugging can be challenging. Therefore, UPS’s enterprise customers are starting to explore the code generators and embedded facilities to be found in .Net and BEA. However hand coding by experienced in-house engineers is a must for the high availability, scalability, and performance that UPS requires for the UPS OnLine Tools.
= Creating a markup file =
</blockquote>
Any text editor can be used to create a markup file (e.g. an HTML file). In this book, we use the text editor within [http://www.NetBeans.org/ NetBeans], an open source '''Integrated Development Environment (IDE)''' for Java, because NetBeans supports editing and validation of XML files. Before proceeding, you should download and install NetBeans from [http://www.NetBeans.org/ www.NetBeans.org]. When the install is complete, take the following actions.
 
<blockquote style="background: linen; border: 1px solid black; padding: 1em;">
== NetBeans IDE 4.0 Beta 2 instruction ==
XML is a convertible meta language which supports the electronic commerce by sticking to certain rules.
# Launch NetBeans
</blockquote>
# Make yourself familiar with the IDE by opening Help > Help Contents and reading the material in Getting Started
# Create a new projfect by File > New Project.. (Ctrl+Shift+N)
# Under "Choose a Project:" select under Catergories: Standard
# Select under Projects: Java Application
# Hit Next
# Name the project name appropriately
# Save to the appropriate location
# Un-check "Set as Main Project" and un-check "Create Main Class"
# Hit Finish
# Create a new file by File > New File (Ctrl+N)
# Select the appropriate project
# Under "Choose a File Type" select under Catergories: XML
# Select under File Types: XML Document
# Name the project name appropriately
# Save to the appropriate location
# Hit Next
# Select "Well-Formed Document"
# Hit Finish
# You should see the following skeleton XML file
 
== Creating a markup file ==
<table width="100%" border="1" cellspacing="0" cellpadding="0">
Any text editor can be used to create a markup file (e.g. an HTML file). In this book, we use the text editor within [http://www.NetBeans.org/ NetBeans], an open source '''Integrated Development Environment (IDE)''' for Java, because NetBeans supports editing and validation of XML files. Before proceeding, you should download and install NetBeans from [http://www.NetBeans.org/ www.NetBeans.org].
<tr>
<td><?xml version="1.0" encoding="UTF-8"?><br/>
<br/>
<!--<br/><i>
Document : FILE_NAME.xml<br/>
Created on : October 5, 2004, 4:37 PM<br/>
Author : Brad<br/>
Description:<br/>
Purpose of the document follows.<br/>
--><i/><br/>
<br/>
<root><br/>
<br/>
</root></td>
</tr>
</table>
 
# Our goal is to create a generic markup file, rather than an XML file, so replace the lines in the skeleton XML file with the four lines in Table 1
# Check the markup file is well-formed by clicking on the green triangle (Alt+F9) on the tool bar. It should pass the check
# Delete the tag </city> and check the file again. This time you should get an error indicating that an end tag is missing
 
== Netbeans/Alternative ==
<font color="SaddleBrown">
The examples here use Netbeans to illustrate proper XML code. For an alternative to Netbeans, look at [[XML: Managing Data Exchange/Exchanger XML Lite as an alternative to NetBeans]]
 
<table width="100%" border="1" bgcolor="lightgreen">
<tr>
<td><b>
Section summary: As NetBeans sticks to XML rules it is favored for creating a markup file.
</b></td>
</tr>
</table>
 
=Why is this book not an XML document?=
</td></tr></table>
 
== Exercise 1 ==
 
Use NetBeans to create a markup file describing a restaurant. The markup should identify the name and address of the restaurant and the type of food or foods in which it specializes.
 
 
== Exercise 2 ==
 
Let's assume we want to create a personal file for a smaller company.
What kind of data do we have?
Analyse the data from following table. Our goal is to transform it into a markup file.
Name of the company: 'Exercises inc.'
 
<TABLE width="100%" border="1" cellspacing="0" cellpadding="0">
<TR bgcolor="#ffff00">
<TD>firstname</TD>
<TD>lastname</TD>
<TD>street</TD>
<TD>city</TD>
<TD>country</TD>
<TD>date_of_birth</TD>
<TD>phone number</TD>
<TD>department</TD>
<TD>title</TD>
</TR>
<TR>
<TD>Tobias</TD>
<TD>Boeswald</TD>
<TD>Laxenburger str. 384</TD>
<TD>Vienna</TD>
<TD>Austria</TD>
<TD>02/07/1974</TD>
<TD>0431/3445346</TD>
<TD>finance and accounting</TD>
<TD>Accountant</TD>
</TR>
<TR>
<TD>Dimitri</TD>
<TD>Felber</TD>
<TD>Neuburger str. 19a</TD>
<TD>Passau</TD>
<TD>Germany</TD>
<TD>05/12/1967</TD>
<TD>00498510/523456</TD>
<TD>finance and accounting</TD>
<TD>CFO</TD>
</TR>
<TR>
<TD>Stefan</TD>
<TD>Meyer</TD>
<TD>Breite Gasse 10</TD>
<TD>Nuremberg</TD>
<TD>Germany</TD>
<TD>10/09/1972</TD>
<TD>00499110/45365</TD>
<TD>human resources</TD>
<TD>HR Manager</TD>
</TR>
</TABLE>
All data is fictitious.
Any similarity between the people described and any real person is purely coincidental. :)
 
</font>
 
= Why is this book not an XML document? =
If you have accepted the ideas presented in this chapter, the question is very pertinent. The simple answer is that we have been unable to find the technology to support the creation of an open text book in XML. We need several pieces of technology
* An XML language for describing a book. [http://www.docbook.org/ DocBook] is such a language, but the structure of a book is quite complex, and DocBook (reflecting this complexity) cannot be quickly mastered
Line 308 ⟶ 188:
 
There is a project to create [http://wiki.wikiml.org/index.php?WikiMl WikiMl] (Wiki MarkupLanguage), and this might be used at some point.
 
= References =
 
'''Initiating author''' [mailto:rwatson@terry.uga.edu Richard T. Watson], University of Georgia