XML Developer Tip
(Receive this column in your inbox,
click Edit your Profile to subscribe.)
Effective XML Markup Presentation
XML expert Kyle Downey has a great story in the latest issue of XML.com's online magazine, entitled "XML Source Highlighting." For people (like me) who must often write about markup—be it XML, HTML, or whatever—in the same documents where markup must otherwise be interpreted to display properly, this can be a vexing problem. In different terms, the issue at work here is to develop tools or techniques that let you present markup as such when you want to use it for listings or examples, but to let you use markup for document rendering otherwise.
Then, too, there's often the issue of dealing with markup and its representations in environments that may be perfectly able to handle literal strings of markup (when instructed to do so properly) but that may not be able to render that markup at all (for example, when using older Web browsers to view documents that include XML source, XSLT transformations, and so forth). I think Downey speaks for everyone who writes about markup when he says that one of his goals in creating documents is "to blend source and documentation without cut and paste."
Downey goes on to review some traditional techniques for handling such needs, and also explains their shortcomings:
- Using character data (CDATA) sections to capture literal character data without interpretation in XML source (works fine if XML is parsed, not so well otherwise).
- Defining entities for examples, so they can be referenced when needed. This doesn't look like ordinary markup and may confuse novices, requires proper definition and external file access, and requires that definitions and references be widely separated within a document's structure.
To deal with these issues, and to make it easy to reference documents or other types of source code in line, Downey creates a highlight mechanism that permits access to external XML documents, other types of source code, or even in-line XML or other markup fragments. His mechanism relies on adding a special markup element (what he calls a "tag") so that the same approach works for all types of markup references, and which make it easier to apply XML transformations to create clean, readable XHTML as output.
It's elegant, easy to use, makes perfect sense to experts and novices alike, and best of all it's free for the using. Learn more about highlight's capabilities and the related software tool Downey has created at www.xml.com. Definitely worth getting to know!
About the Author
Based in Austin, TX, Ed Tittel is a principal content developer, and also a writer, trainer, and consultant for Capstar a full-service e-learning company headquartered in Princeton, NJ.
For More Information:
- Looking for free research? Browse our comprehensive White Papers section by topic, author or keyword.
- Are you tired of technospeak? The Web Services Advisor column uses plain talk and avoids the hype.
- For insightful opinion and commentary from today's industry leaders, read our Guest Commentary columns.
- Hey Codeheads! Start benefiting from these time-saving XML Developer Tips and .NET Developer Tips.
- Visit our huge Best Web Links for Web Services collection for the freshest editor-selected resources.
- Visit Ask the Experts for answers to your Web services, SOAP, WSDL, XML, .NET, Java and EAI questions.
- Choking on the alphabet soup of industry acronyms? Visit our helpful Glossary for the latest industry lingo.
- Couldn't attend one of our Webcasts? Don't miss out. Visit our archive to watch at your own convenience.
- Discuss this article, voice your opinion or talk with your peers in the SearchWebServices Discussion Forums.