In: Categories » » HTML XHTML and CSS » Extending XHTML
Fragmenting XHTML is useful if you want to implement portions of XHTML, but many developers need to go the other direction and supplement XHTML's functionality. Fortunately, you can use the exact same set of tools the W3C used to create the XHTML modules to create your own modules. One of the editors of the XHTML drafts, Murray Altheim, has published some tools and templates that may help you get started. It isn't easy, but it's not exactly rocket science either. Of course, defining the markup alone doesn't transform user's Web browsers instantly – you still have to perform a lot of software development (or, at the very least, style sheet development) to make your shiny new vocabularies work.
Tip You really only need to read this article if you plan to build your own extensions to XHTML or you need to understand how new modules from various sources integrate with XHTML. If that isn't your goal right now, skip ahead and come back if you need this material.
Building Your Own Modules The first part you need to define is the content of your XHTML module. You may be starting from scratch, building your module on the XHTML DTD framework, or converting an existing XML DTD to an XHTML module. In any case, creating an XHTML module involves a good deal more work and tends to produce a much more verbose document description than creating an ordinary XML DTD. You must combine the basic tools described in Article 6 with the approach described in Article 15, and you should document your work in an abstract module that goes beyond simple DTD creation. While there is definitely extra work involved in creating a formal XHTML module that uses all the parameterization conventions created by the W3C, this approach should produce a more usable result.
Caution You can create modules that work without using the parameter entity and conditional sections approach. After all, modules are just DTDs, and parsers won't care about how many parameter entities or conditional sections you used to create the DTD. On the other hand, developers outside of your project may have a much harder time working with and integrating your vocabulary into their work. Even if you're just prototyping, starting out with and sticking to the XHTML approach makes the management of your modules much easier. For the most part, building an XHTML module means creating your own vocabulary and laying it out as a set of elements and attributes. It's basically the same as creating an XML vocabulary, with a few extra pieces. I don't cover the ins and outs of creating XML vocabularies here, as that task is well described in (and requires) lots of separate articles. Instead, I walk you through a very simple but plausible XHTML module for describing biographical information within XHTML documents.
Note Lots of articles describe how to create your own XML vocabularies. XML: A Primer (Simon St. Laurent, IDG Articles, 1999) describes XML and provides numerous examples, while XML Elements of Style (Simon St. Laurent, McGraw- Hill, 2000) goes into much more detail about the rules and traps of XML. The XML Bible (Elliotte Rusty Harold, IDG Articles, 1999) runs through a series of baseball-oriented examples in detail. David Megginson's Structuring XML Documents (Prentice-Hall, 1998) moves more into SGML, but provides detailed descriptions of various approaches to XML document structure.
Tip If you want to get a head start on your module creation and avoid some of the work described in the next few sections, take a look at archy and instance karma. Both are from Murray Altheim, one of the editors of XHTML 1.1. archy (available http://www.doctypes.org/archy/home.html) is a framework for building XHTML modules, while instance karma (available at http://www.doctypes.org/instkrma/home.html) is an XSLT style sheet that builds a shell DTD from a sample document. If you want to start by creating sample documents, this approach can save you a lot of time. The XHTML-Biography module you create in this article can include and be included in XHTML 1.1 documents, which means that the customization file is especially important. Most of the functionality provided by the module doesn't require extra processing beyond the capabilities of relatively simple cascading style sheets, so you can put the module to work in browsers easily. Non-browser application structures, such as filters that search for information on particular people, can treat the XHTML documents created with this module as XML and seek out the markup vocabulary you create to track down biographical information. In planning the module, you design for two different kinds of situations and try to accommodate both. The first case is a formal biography, a description within an HTML document that provides a complete biography of a person possibly presented in a different way than the rest of an HTML document. These formal biographies use the markup you create here for their basic structures, and a mixture of ordinary HTML and biographical markup for their contents. The second case enables developers to mark up biographical information within other XHTML documents without the trouble of a full biography. It might point to a formal biography, or it might help automated processors track down documents that contain information about a particular person. This approach is very useful for news sites because it lets them build search engines, for instance, to supplement this module with other modules describing companies and other organizations. To identify your elements, use this namespace:
http://www.simonstl.com/xhtml/xhtml-biography/ Within the DTD and abstract modules, use the prefix biog. (Using bio invites conflicts with biology and changing the prefix can break validation, as described later in this article.) Let's start by creating an abstract module that describes what you're doing here, and then move into the formalities of building a DTD using the XHTML conventions. You need to create elements for identifying biographies when they appear in documents, and these can act as containers for a more formal set of descriptions. Then you create a separate container for identifying people within ordinary XHTML content. Working inside of XHTML documents may require a much more flexible approach while still describing similar information. Neither of these elements needs many attributes beyond the Common core. You can use the id and class attributes if needed to identify particular biography information sets within a document. The biog:person element can have a more attribute pointing to a fuller set of information about the person, if appropriate. The content model for biog:biography is much stricter than that for biog:person, but to a sizable extent that is because you plan to have substantially more control over the content and presentation of biog:biography elements. The biog:person element type must demonstrate more flexibility in order to be useful; it should work in situations in which only partial information is available, as well as in a wider variety of sequences.
Apart from biog:name, all of these elements only contain text. Because names may appear in different orders in different cultures, biog:name has become extremely flexible (perhaps too flexible). You can specify more parts for all of these – the title can refer to the position and the organization or location to which it applies, and the birth and death dates can break down into year, month, and day. For now, let's use date as a placeholder for PCDATA to make its contents more explicit. (This has no effect on parsing.) It's also possible that these items should permit inline HTML elements as well, but let's opt not to do that for now. This should be all the abstract model you need, so let's move on to building the DTD module and making use of XHTML 1.1's set of naming conventions. Start by declaring the date data type:
<!ENTITY % date.datatype "#PCDATA">
You don't have any classes or mixes defined in this module, but you use classes defined in XHTML (Block and Inline) to define content models in your element declarations. First you define your elements as suggested in the XHTML specifications, creating a parameter entity that contains the element content model, and then you use that parameter entity in the element type declaration.
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 ...
