In: Categories » » HTML XHTML and CSS » Is Formal XHTML Module Inclusion Worth the Trouble
Inline and mixed-up markup Sometimes you may want to mix the HTML vocabulary with your own vocabulary at a very low level. A number of XML DTDs include the ubiquitous b and i element types for bold and italic; more use of HTML vocabulary types may make sense in your own markup. While this does not produce documents intended for a Web browser necessarily (unless you produce style sheets that make your XML readily presentable), it can make it easier to create document types without reinventing the wheel entirely. You can use HTML element names in your own XML without creating any (official) conflict with XHTML, provided that you don't use an HTML or XHTML namespace to identify your elements.
While your document structures may look like familiar XHTML to you, applications identify the information as belonging to your vocabulary rather than the XHTML vocabulary and rely on style sheets that you create for formatting or processing. There are some limits to this – as previously noted, images and scripts are especially difficult to process without using the functionality that browsers support for HTML. Still, if you only need to include a small fragment of familiar markup, this may be an appropriate route. If you want to stick to identifying XHTML as XHTML, you can – although you probably need to use namespace prefixes (and the default namespace, no prefix) to distinguish between your own vocabulary and the XHTML vocabulary. While it might seem obvious to you (or to document authors), it isn't so obvious to the programs processing your documents.
Is Formal XHTML Module Inclusion Worth the Trouble? The W3C has put forth a number of specifications that offer different approaches to mixing XML and XHTML, and the browser vendors (as previously noted) have focused on only one of those approaches – using namespaces to separate XML from HTML vocabulary. This approach doesn't require any DOCTYPE magic, nor do you have to create and manipulate parameterized XHTML DTDs. At the same time, however, you definitely lose something by skipping out on the DTD creation process described in the last article.
Caution As of this writing, none of the available browsers actually support the XHTML namespace (http://www.w3.org/1999/xhtml) as an identifier for HTML vocabularies. Using the namespace they do support (http://www.w3.org/TR/REC-html40) means that your documents don't conform to even the namespace end of XHTML, despite conforming otherwise. While it may be useful as a stopgap measure, be prepared for a massive search and replace when (and if) XHTML becomes the standard. XML 1.0 made a deliberate point of not requiring a DTD or even a DOCTYPE declaration for documents – although this lack of a DTD bars these documents from being used with a certain class of parsers, called validating parsers. Most browsers use non-validating parsers for processing XML and HTML. (Microsoft's built-in parser can be told to validate, but it doesn't normally validate when loading documents for display.) As a result, these tools don't check documents for conformance to an XHTML DTD. They also don't check the modules you create in addition to the XHTML DTD.
However, many other kinds of processors may check your documents against the DTD your documents specify, and they may reject documents that don't specify a DTD for such examination. If your documents have to deal with such parsers – which is likely if you exchange business information within your documents – the extra work of building XHTML DTD modules is worth the cost. (You need to create a DTD for your extensions anyway.) The modular and parameterized approach taken by XHTML 1.1 can help you manage and eventually extend the vocabulary and structures you create. Even if you don't know in advance that your documents will be subject to such inspection, you may find it useful to build an XHTML DTD module that provides a formal description of what you're doing. To a certain extent, it's a documentation process that codifies the work you do, while making it easier to share with others. This module also provides insurance against a future in which your documents may have to be fed into validating XML parsers, avoiding a major crunch. By creating constraints early, you can avoid producing a monstrous number of variations on your structures and make them more manageable. Having a DTD enables you to use a wider set of tools, as valid documents that conform to a specified DTD can be parsed by both validating and non-validating parsers and used in the applications built on those parsers.
While it may not be necessary in every case to build a formal description of what your extensions to XHTML are and how they integrate with the XHTML vocabulary, you definitely should consider the process as your documents move from prototypes and experiments to full-scale production. It's more than insurance against a changing future – it's an opportunity to learn about how you structure information and how to make necessary corrections early.
legal notice
Our website is not responsible for the information contained by this article. Web-articles is a free articles resource.
Suggestion: If you need fresh, daily updated content for your website, feel free to use our service. Click here for more information.
Useful tools and features
related articles
Overview Shifting from HTML to XHTML requires a significant change in mindset from the design-oriented freefor- all that characterized the early years of the Web. This change in style reflects movement in the underlying architecture toward a more powerful and more controllable approach to document creation, presentation, and management. Understanding the connections between the architectural and stylistic changes may help you find more immediate benefits from XHTML –...
2. Coding Styles HTMLs Maximum Flexibility
The XHTML 1.0 specification provides a set of rules for XHTML (User Agent Conformance) that includes a rough description of how XHTML software differs from HTML software, though these rules exist mostly to bring XHTML rendering practice in line with the rules for parsing XML 1.0. XHTML also is designed to remain compatible (mostly) with the previous generation of HTML applications, so it may take a while for the transition to occur. Pure XHTML user agents (also known as XHTML processing software) aren't l...
3. XML and XHTMLs Maximum Structure
Coding Styles— XML and XHTML's Maximum Structure Overview XML parsers are far more brutal about rejecting documents they don't like than are HTML browsers. XML's clear focus on structure demands that the practices described in the previous chapter must change. However, most of those changes shouldn't cause more than minor inconveniences – at least for newly created documents. Note If reading this chapt...
4. XML and CDATA
Processing instructions XML also enables developers to pass information to the application through processing instructions (often called PIs). Processing instructions use a similar syntax to the XML declaration, although the rules for them are much less strict. Processing instructions begin with <? and end with ?>, but the developer generally dictates their contents. The first bit of text before a space appears in a PI is called the target. The target must start with a letter, unde...
5. lang Internationalization
Internationalization: xml:lang and lang Internationalization (often abbreviated i18n because 18 characters appear between the i and the n) gets a significant boost with the shift to XML primarily because of XML's use of Unicode as the underlying character model. While not every document needs to encode Chinese, Cyrillic, Arabic, and Indian characters, Unicode makes it possible for all of these forms to exist within a single document. In addition, XML and XHTML allow for the possibility of other e...
6. Anatomy of an XHTML Document
The transition from HTML to XHTML will come with a fair number of bumps. While later chapters introduce tools to help you get past those bumps – and figure out where they come from – this chapter examines what's going to change and demonstrates a few strategies for handling those changes. Along the way, we visit the ghosts of browsers past and explore problems that exist in current browsers. In turn, you discover how prepared and unprepared various tools are for XHTML. Note Som...
7. Converting to strict HTML and XHTML
Converting to strict HTML You start out by declaring your intentions to use the strict HTML 4.01 DTD by putting the appropriate DOCTYPE declaration at the head of the document: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> Now the first section of the document, including the HTML opening tag and the HEAD element and its contents, is fine except for one line. The SCRIPT element no longer supports a LANGUAGE at...
8. Reading the XHTML DTDs A Guide to XML Declarations
Reading the XHTML DTDs: A Guide to XML Declarations Although the W3C has long had document type definitions (DTDs) for HTML, few developers actually use those DTDs as a foundation for learning HTML. XHTML 1.0 simplifies those DTDs with the slightly friendlier XML syntax – they previously used SGML's more complex syntax – and the increased emphasis on validation may lead developers to explore them more closely. Making good use of XHTML 1.1 requires some level of ...
9. Defaulting attribute values XHTML DTDs
XML 1.0 also provides a set of tools for specifying what happens if an attribute isn't declared within an element. Four different possibilities exist, including "the attribute just isn't there"; "the attribute must be there, period"; and "the attribute has this value, period." You already have seen a few uses of these choices in the preceding declarations. In the img element, for instance, the src and alt attributes are required (#REQUIRED); meanwhile, most of the rest of its attribute content is optio...
10. Exploring the XHTML DTDs
Exploring the XHTML DTDs Choosing Your DTD XHTML 1.0 provides three DTDs that describe different sets of XHTML elements and reflect the three choices provided in HTML 4.0: strict, transitional, and frameset. The probably the one that the W3C would like to see developers adhere to, but transitional DTDs reflect the reality of HTML usage much more accurately. Appendix A lists the in the three different DTDs, along with notes regarding attributes. To identify the DTD for a ...
