Help with the example

The planning behind the XML/XSL/DTD files

This file is written using the standard CODEHELP XML/XSL/DTD combination. This ensures that it fits in with the rest of the site effortlessly. The standard files are designed to provide a common background, easy link creation, controlled and justified text that is restricted to a more readable newspaper type column instead of using the entire width of the page.

The example is written with a much reduced set of files. The process starts with the XML file itself. This needs to be planned carefully if your later work on the XSL and DTD are not to be completely wasted. Start with a clear idea of the data and the formatting. This is not as easy as it sounds. Is the following data or formatting?

<input type="password" name="pass" size="10" />

It is neither. Not until you decide on what it can be. In each document you are only likely to need one password input box and that box might as well be the same in each document to allow the script to process the form data efficiently. So in most cases this line is formatting. Strange? The box contains data once viewed, but it does not contain code that needs to be any different between pages. The line above can be either added to the XSL - so all documents have a password box - or as a single tag in the XML that instructs the XSL to insert the above code exactly as is.

<PASSWORD />

If the <password /> tag is not in any one XML file, the password box is not added to the document. Easy. The control does not change between documents - it doesn't need to. The attributes and values in the final HTML tag do not need to change between documents, so the entire tag can be entered as one. Now consider a text input.

<input type="text" name="mytext1" size="50" />

In this example, it is quite likely that you will have more than one text input in any one form. Each one will have the type="text" so that is not data. Each one will need a unique name and may need a size different from other inputs in the same form. So the XML could be:

<TEXTINPUT>
<NAME>mytext2</NAME>
<SIZE>60</SIZE>
</TEXTINPUT>

Notice the nesting of the tags. This will need to be stated explicitly in the DTD that you will write later. An XML editor is essential for this stage.



This is part of www.codehelp.co.uk Copyright © 1998-2004 Neil Williams
See the file about.html for copying conditions.