|
||
| Inside Technique : Building Documents with XML, XSL, and CSS : Our XML Article Format For this article, we created a simple XML-schema to demonstrate a simple article format. Looking at most of our articles, they consist of a title, a set of keywords, the author's name, and a list of chapters each with its own title. In our XML schema we expose the document in two parts. If you are familiar with HTML, authoring XML is very simple. Instead of using HTML's built-in tags, you will be using tags specific to your purpose. We are going to explore our simple article format. The article contains a single header section stored in a meta block following by n-number of chapters representing each page of the article: <?xml version="1.0"?> <?xml:stylesheet type="text/xsl" href="simple.xsl" ?> <article> <meta> ... Title, keywords, author, ... </meta> <chapter> <title>...title...</title> <body>...chapter body...</body> </chapter> <chapter> <title>...title2...</title> <body>...chapter body2...</body> </chapter> </article> Looking closer at our meta section, we defined 5 elements - a title element, an author element, a date element, and a keyword element. You are limited to one of each element except for keyword which can be specified multiple times to define multiple keywords. For example: <meta> <title>Sample Article Template</title> <abstract>We explore using XML and XSL to create a simple article template.</abstract> <author email="scotti@SiteExperts.com">Scott Isaacs</author> <date>6/12/1999</date> <keyword>XML</keyword> <keyword>XSL</keyword> </meta> Each chapter contains two sections, a title and a body section. Inside the body section we expose a very simple set of tags for creating your content. You can create either <p>aragraphs or <code> blocks. Within each paragraph you can mark text that you want used in pullquotes. For example: <chapter> <title>Introduction</title> <p>You can create <pullquote>templates with XML and XSL<pullquote> For example: </p> <code> ...put code here... </code> </chapter> Typically you would use a DTD to describe the elements in the document. However, for simplicity purposes we are leaving the discussion of DTDs for a future article. The DTD would be used to define the valid elements and attributes, the ordering of the elements, whether the element is required, and whether the element can be repeated (eg., one title versus multiple keywords). Different from HTML, a document authored using XML has no default presentation. We are now going to explain why XSL is a powerful and necessary tool when building an XML-based site. Page 1:Building Documents with XML, XSL, and CSS © 1997-2000 InsideDHTML.com, LLC. All rights reserved. |