eXtropia: the open web technology company
Technology | Support | Tutorials | Development | About Us | Users | Contact Us
 ::   Tutorials
 ::   Presentations
Perl & CGI tutorials
 ::   Intro to Perl/CGI and HTML Forms
 ::   Intro to Windows Perl
 ::   Intro to Perl 5
 ::   Intro to Perl
 ::   Intro to Perl Taint mode
 ::   Sherlock Holmes and the Case of the Broken CGI Script
 ::   Writing COM Components in Perl

Java tutorials
 ::   Intro to Java
 ::   Cross Browser Java

Misc technical tutorials
 ::   Intro to The Web Application Development Environment
 ::   Introduction to XML
 ::   Intro to Web Design
 ::   Intro to Web Security
 ::   Databases for Web Developers
 ::   UNIX for Web Developers
 ::   Intro to Adobe Photoshop
 ::   Web Programming 101
 ::   Introduction to Microsoft DNA

Misc non-technical tutorials
 ::   Misc Technopreneurship Docs
 ::   What is a Webmaster?
 ::   What is the open source business model?
 ::   Technical writing
 ::   Small and mid-sized businesses on the Web

Offsite tutorials
 ::   ISAPI Perl Primer
 ::   Serving up web server basics
 ::   Introduction to Java (Parts 1 and 2) in Slovak


Introduction to XML For Web Developers
Defining Elements and their Children  

In our previous example, we explained that we had defined an element named CONTACT, that was allowed to include a single ELEMENT NAME, that in turn contained parsed character data.

    <?xml version = "1.0" encoding="UTF-8" standalone = "yes"?>


        <NAME>Roger Kaplan</NAME>


Well, truthfully, we were "mostly" right in our explanation of the DTD. More correctly, the example defined an element named CONTACT that was REQUIRED to have a child NAME.

Remember that DTDs give you quite a bit of flexibility to specify exactly what elements can contain. Using regular expression pattern matching, DTDs allow you to specify very complex logical relationships between elements and their children

For example, you could specify such things as: an element may contain a child, one or more children, zero or more children, or at least one child, You could also specify more complex relationships such as element X is valid if it contains one or more children named Y OR one Child named Z.

Element definitions are described by their Element Content Models (ECM)....that is, all the stuff in the parentheses. :)

Thus, as we saw, the ECM of the CONTACT element specified the child element NAME:


The contents of the ECM are governed by a set of regular expression rules very similar to those used in UNIX. But if you are not familiar with UNIX, don't worry, it is pretty easy. The idea of regular expressions is that certain characters are used to communicate matching logic. Take a look at the possible meta characters....

Character Meaning
+ One or more occurrence
* Zero or more occurrences
? Optional
() A group of expressions to be matched together
| OR...as in, "this or that"
, Strictly ordered. Like an AND

Of course, these are best seen by example. Let's consider the simplest case of defining an order of child elements.

Previous Page | Next Page | Table of Contents