eXtropia: the open web technology company
Technology | Support | Tutorials | Development | About Us | Users | Contact Us
Resources
 ::   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
Either/Or  

The pipe character is used to specify an "OR" operation. Thus, the following DTD snippet would specify an XML document in which all CONTACT elements would have a NAME child followed by either a PHONE or an EMAIL element (but not both).

	<!ELEMENT CONTACT (NAME, (PHONE | EMAIL))>
	<!ELEMENT NAME (#PCDATA)>
	<!ELEMENT EMAIL (#PCDATA)>

Note that XML regular expression matching is not a short circuited system. OR's imply one or the other but not both and not neither. Is that a tongue twister or what!?! Using examples to make my point, here are several invalid XML snippets based on the DTD snippet above....

        <CONTACT>
        <NAME>Jim Sanger</NAME>
        </CONTACT>

That is invalid because the DTD specified that every CONTACT must have either a PHONE or an EMAIL. The above has neither.

        <CONTACT>
        <NAME>Jim Sanger</NAME>
        <EMAIL>Jim Sanger</EMAIL>
        <PHONE>Jim Sanger</PHONE>
        </CONTACT>

This one is invalid because the contact has BOTH EMAIL and PHONE children.

        <CONTACT>
        <EMAIL>Jim Sanger</EMAIL>
        <NAME>Jim Sanger</NAME>
        </CONTACT>

This one is wrong because NAME must appear before EMAIL or PHONE

NOTE: within a grouping, you may use only one connector (such as , or |). Thus, it is invalid to use

	<!ELEMENT CONTACT (NAME, PHONE | EMAIL)>

Instead, you must create a subgroup as shown above

	<!ELEMENT CONTACT (NAME, (PHONE | EMAIL))>

Previous Page | Next Page | Table of Contents