XMLPatterns.com

Home

Introduction

Patterns
Categorized
Alphabetical
Chronological

Books

Links

About
Multiple Document Types
Printable Version

Abstract:

When a system needs to represent a range of different document types, each document type can be represented by a completely separate declarations.


Problem:

A system needs to represent different types of information. This information may be used at different times, or may be used by different parts of the system.


Context:

Systems which need to represent a variety of information at different times or places.


Forces:

Processing and authoring of documents can be simplified if different document types are used to represent different sets of data.


Solution:

Use different document types to represent different sets of data within the system.


Examples:

In a payroll system, data about the Employees, and data about the hours they work can be represented by separate documents.

Employees.dtd:
                            

<!ELEMENT Employee (Name, HourlyRate)>
<!ATTLIST Employee id ID #REQUIRED>

<!ELEMENT Name (#PCDATA)>

<!ELEMENT HourlyRate (#PCDATA)>

                            
                          
HoursWorked.dtd:
                            

<!ELEMENT PayPeriod (Employee+)>
<!ATTLIST PayPeriod
StartDate #CDATA
EndDate   #CDATA>

<!ELEMENT Employee (HoursWorked)>
<!ATTLIST Employee id NMTOKEN>

<!ELEMENT HoursWorked (#PCDATA)>

                            
                          


Discussion:

If different people will authoring the different types of documents it is a good idea to have completely separate document types, because authors will not need to be exposed to parts of the document types that are not needed.

Having separate document types allows the different DTDs to be versioned independently.



Related Patterns:

Universal Root allows multiple types of data under one document root. Multi Root Document Types allows for multiple types of documents to be declared in a single declaration.


Known Uses:



Visit our sponsors: (Interested in advertising on XMLPatterns.com?)