Home > Store

Effective XML: 50 Specific Ways to Improve Your XML

Register your product to gain access to bonus material or receive a coupon.

Effective XML: 50 Specific Ways to Improve Your XML

Book

  • Sorry, this book is no longer in print.
Not for Sale

About

Features

World-renowned author Elliotte Rusty Harold teaches programmers how to use XML effectively and produce code that's just plain better.

° Critical rules of thumb employed by the experts--the things they almost always do or almost always avoid doing--to get the most out of XML.

° Drawing on years of experience, Harold explains 50 ways to use XML to produce code that is extensible, legible, and maintainable.

° The latest addition to Scott Meyers' Effective Software Development Series.

Description

  • Copyright 2004
  • Dimensions: 7" x 9-1/4"
  • Pages: 336
  • Edition: 1st
  • Book
  • ISBN-10: 0-321-15040-6
  • ISBN-13: 978-0-321-15040-0

Learning the fundamentals of XML might take a programmer a week. Learning how to use XML effectively might take a lifetime. While many books have been written that teach developers how to use the basic syntax of XML, this is the first one that really focuses on how to use XML well. This book is not a tutorial. It is not going to teach you what a tag is or how to write a DTD (Document Type Definition). Instead it's going to tell you when, why, where, and how to use such tools effectively (and equally important when not to use them).Since XML has become a fundamental underpinning of new software systems, it becomes important to ask new questions, not just what XML is, but how does one use it effectively? Which techniques work and which don't? Perhaps most importantly, which techniques appear to work at first but fail to scale as systems are further developed? This book answers these questions. It is not enough to write programs that compile and produce the expected results. It is important to write code that is extensible, legible, and maintainable. XML can be used to produce robust, extensible, maintainable systems.

Extras

Related Article

Parsing XML with Visual C++

Items

Untitled Document Read Sample Items from Effective XML: 50 Specific Ways to Improve Your XML

Item 1: SYNTAX

Item 3: Stay with XML 1.0

Item 29: Always Use a Parser

Item 37: Validate Inside Your Program with Schemas

Sample Content

Online Sample Chapters

Item 29: Always Use a Parser

Item 3: Stay with XML 1.0

Item 37: Validate Inside Your Program with Schemas

Table of Contents



Preface.


Acknowledgments.


Introduction.

Element versus Tag.

Attribute versus Attribute Value.

Entity versus Entity Reference.

Entity Reference versus Character Reference.

Children versus Child Elements versus Content.

Text versus Character Data versus Markup.

Namespace versus Namespace Name versus Namespace URI.

XML Document versus XML File.

XML Application versus XML Software.

Well-Formed versus Valid.

DTD versus DOCTYPE.

XML Declaration versus Processing Instruction.

Character Set versus Character Encoding.

URI versus URI Reference versus IRI.

Schemas versus the W3C XML Schema Language.

I. SYNTAX.

Item 1. Include an XML Declaration.

The version Info.

The encoding Declaration.

The standalone Declaration.

Item 2. Mark Up with ASCII if Possible.
Item 3. Stay with XML 1.0.

New Characters in XML Names.

C0 Control Characters.

C1 Control Characters.

NEL Used as a Line Break.

Unicode Normalization.

Undeclaring Namespace Prefixes.

Item 4. Use Standard Entity References.
Item 5. Comment DTDs Liberally.

The Header Comment.

Declarations.

Item 6. Name Elements with Camel Case.
Item 7. Parameterize DTDs.

Parameterizing Attributes.

Parameterizing Namespaces.

Full Parameterization.

Conditional Sections.

Item 8. Modularize DTDs.
Item 9. Distinguish Text from Markup.
Item 10. White Space Matters.

The xml:space Attribute.

Ignorable White Space.

Tags and White Space.

White Space in Attributes.

Schemas.

II. STRUCTURE.

Item 11. Make Structure Explicit through Markup.

Tag Each Unit of Information.

Avoid Implicit Structure.

Where to Stop?

Item 12. Store Metadata in Attributes.
Item 13. Remember Mixed Content.
Item 14. Allow All XML Syntax.
Item 15. Build on Top of Structures, Not Syntax.

Empty-Element Tags.

CDATA Sections.

Character and Entity References.

Item 16. Prefer URLs to Unparsed Entities and Notations.
Item 17. Use Processing Instructions for Process-Specific Content.

Style Location.

Overlapping Markup.

Page Formatting.

Out-of-Line Markup.

Misuse of Processing Instructions.

Item 18. Include All Information in the Instance Document.
Item 19. Encode Binary Data Using Quoted Printable and/or Base64.

Quoted Printable.

Base64.

Item 20. Use Namespaces for Modularity and Extensibility.

Choosing a Namespace URI.

Validation and Namespaces.

Item 21. Rely on Namespace URIs, Not Prefixes.
Item 22. Don't Use Namespace Prefixes in Element Content and Attribute Values.
Item 23. Reuse XHTML for Generic Narrative Content.
Item 24. Choose the Right Schema Language for the Job.

The W3C XML Schema Language.

Document Type Definitions.

RELAX NG.

Schematron.

Java, C#, Python, and Perl.

Layering Schemas.

Item 25. Pretend There's No Such Thing as the PSVI.
Item 26. Version Documents, Schemas, and Stylesheets.
Item 27. Mark Up According to Meaning.

III. SEMANTICS.

Item 28. Use Only What You Need.
Item 29. Always Use a Parser.
Item 30. Layer Functionality.
Item 31. Program to Standard APIs.

SAX.

DOM.

JDOM.

Item 32. Choose SAX for Computer Efficiency.
Item 33. Choose DOM for Standards Support.
Item 34. Read the Complete DTD.
Item 35. Navigate with XPath.
Item 36. Serialize XML with XML.
Item 37. Validate Inside Your Program with Schemas.

Xerces-J.

DOM Level 3 Validation.

IV. IMPLEMENTATION.

Item 38. Write in Unicode.

Choosing an Encoding.

A char Is Not a Character.

Normalization Forms.

Sorting.

Item 39. Parameterize XSLT Stylesheets.
Item 40. Avoid Vendor Lock-In.
Item 41. Hang On to Your Relational Database.
Item 42. Document Namespaces with RDDL.

Natures.

Purposes.

Item 43. Preprocess XSLT on the Server Side.

Servlet-Based Solutions.

Apache.

IIS.

Item 44. Serve XML+CSS to the Client.
Item 45. Pick the Correct MIME Media Type.
Item 46. Tidy Up Your HTML.

MIME Type.

HTML Tidy.

Older Browsers.

Item 47. Catalog Common Resources.

Catalog Syntax.

Using Catalog Files.

Item 48. Verify Documents with XML Digital Signatures.

Digital Signature Syntax.

Digital Signature Tools.

Item 49. Hide Confidential Data with XML Encryption.

Encryption Syntax.

Encryption Tools.

Item 50. Compress if Space Is a Problem.
Recommended Reading.
Index. 0321150406T08272003

Preface

Learning the fundamentals of XML might take a programmer a week. Learning how to use XML effectively might take a lifetime. While many books have been written that teach developers how to use the basic syntax of XML, this is the first one that really focuses on how to use XML well. This book is not a tutorial. It is not going to teach you what a tag is or how to write a DTD. I assume you know these things. Instead it's going to tell you when, why, where, and how to use such tools effectively (and perhaps equally importantly when not to use them). This book derives directly from my own experiences teaching and writing about XML. Over the last five years. I've written several books and taught numerous introductory courses about XML syntax, APIs, and tools. Increasingly I'm finding that audiences are already familiar with the basics of XML. They know what a tag is, how to validate a document against a DTD, and how to transform a document with an XSLT style sheet. The question of what XML is and why to use it has been sufficiently well evangelized. The essential syntax and rules are reasonably well understood. However, although most developers know what a CDATA section is, they are not sure what to use one for. Although programmers know how to add attribute and child nodes to elements, they are not certain which one to use when.

Since XML has become a fundamental underpinning of new software systems, it becomes important to begin asking new questions, not just what XML is, but how does one use it effectively? Which techniques work and which don't? Perhaps most importantly, which techniques appear to work at first but fail to scale as systems are further developed? When I teach programming at my university, one of the first things I tell my students is that it is not enough to write programs that compile and produce the expected results. It is as important (perhaps more important) to write code that is extensible, legible, and maintainable. XML can be used to produce robust, extensible, maintainable, comprehensible systems or it can be used to create masses of unmaintainable, illegible, fragile, closed code. In the immortal words of Eric Clapton, "It's in the way that you use it." XML is not a programming language. It is a markup language; but it is being successfully used by many programmers. There have been markup languages before, but in the developer community XML is far and away the most successful. However, the newness and unfamiliarity of markup languages have meant that many developers are using it less effectively than they could. Many programmers are hacking together systems that work, but are not as robust, extensible, or portable as XML promises. This is to be expected. Programmers working with XML are pioneers exploring new territory, opening up new vistas in software, and accomplishing things that could not easily be accomplished just a few years ago. However one definition of a pioneer is someone with an arrow in their back, and more than a few XML pioneers have returned from the frontier with arrows in their backs.

Five years after the initial release of XML into the world, certain patterns and antipatterns for the proper design of XML applications are becoming apparent. All of us in the XML community have made mistakes while exploring this new territory, the author of this book prominently among them. However, we've learned from those mistakes, and we're beginning to develop some principles that may help those who follow in our footsteps to avoid making the same mistakes we did. It is time to put up some caution signs in the road. We may not exactly say "Here there be dragons", but we can at least say, "That road is a lot rockier than it looks at first glance, and you might really want to take this slightly less obvious but much smoother path off to the left."

This book is divided into four parts beginning with the lowest layer of XML and gradually working up to the highest:

  • Part I covers XML syntax, those aspects of XML that don't really affect the information content of an XML document, but may have large impacts on how easy or hard those documents are to edit and process.
  • Part II looks at XML structures, the general organization and annotation of information in an XML document.
  • Part III discusses the various techniques and APIs that are available for processing XML with languages such as C++, C#, Java, Python, and Perl and thus local semantics to the labeled structures of XML.
  • Part IV explores effective techniques for systems built around XML documents, rather than looking at individual documents in isolation.

Although, this is how I've organized the book, you should be able to begin reading at essentially any chapter. This book makes an excellent bathroom reader. :-) You may wish to read the introduction first, which defines a number of key terms that are used throughout the book, and which are frequently misused or confused. However, after that feel free to pick and choose from the topics as your interest and needs dictate. I've made liberal use of cross-references to throughout to direct you along other paths through the book that may be of interest.

I hope that this book is a beginning, not an end. It's still early in the life of XML, and much remains to be discovered and invented. You may well develop best practices of your own that are not mentioned here. If you do I'd love to hear about them. You may also take issue with some of the principles stated here. I'd like to hear about that too. Discussion of many of the guidelines identified here has taken place on the xml-dev mailing list, and seems likely to continue in the future. If you're interested in further discussion of the issues raised in this book, I recommend you subscribe and participate there. Complete details can be found at http://lists.xml.org/. On the other hand, if you find out and out mistakes in this book (The ID attribute value on p. 87 is missing a closing quote. The word "Cat" is misspelled on p. 46.) you can write me directly at elharo@metalab.unc.edu. I maintain a web page listing known errata for this book, as well as any updates at http://www.cafeconleche.org/books/effectivexml/. I hope this book makes your use of XML both more effective and more enjoyable.

—Elliotte Rusty Harold
elharo@metalab.unc.edu
Brooklyn NY
April 22, 2003



0321150406P06062003

Index

Download the Index file related to this title.

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020