# XML - Managing Data Exchange/Data schemas

------------------------------------------------------------------------

+----------------------------------+----------------------------------+
| ``{=html}**Learning | \                                |
| objectives**`</span>`{=html}\    |                                  |
| \*                               | ```{=html}                       |
| `<span st                        | <div class="center">             |
| yle="font-size:medium;">`{=html} | ```                              |
| Overview of Data                 | `<big>`{=html}`<big>`{=html}The  |
| Schemas`</span>`{=html}          | University of                    |
|                                  | Georgi                           |
| -   `<span st                    | a`</big>`{=html}`</big>`{=html}\ |
| yle="font-size:medium;">`{=html} | \                                |
|     Starting your schema the     | `<big>`{=html}`<big>`{=          |
|     right way`</span>`{=html}    | html}`<big>`{=html}`<span style= |
| -   `<span st                    | "color:#990000;">`{=html}**Terry |
| yle="font-size:medium;">`{=html} | College of                       |
|     Entities in                  | Business                         |
|     general`</span>`{=html}      | **`</span>`{=html}`</big>`{=html |
| -   `<span st                    | }`</big>`{=html}`</big>`{=html}\ |
| yle="font-size:medium;">`{=html} | \                                |
|     The Parent Child             | `<big>                           |
|     Structure`</span>`{=html}    | `{=html}`<big>`{=html}Department |
| -   ``{=html} | Syste                            |
|     Attributes and               | ms`</big>`{=html}`</big>`{=html} |
|     Restrictions`</span>`{=html} |                                  |
| -   `<span st                    | ```{=html}                       |
| yle="font-size:medium;">`{=html} | </div>                           |
|     Ending your schema the right | ```                              |
|     way`</span>`{=html}          |                                  |
+----------------------------------+----------------------------------+

## Introduction

Data schemas are the foundation of all XML pages. They define objects,
their relationships, their attributes, and the structure of the data
model. Without them, XML documents would not exist. In this chapter, you
will come to understand the purpose of XML data schemas, their intricate
parts, and how to utilize them. Also, examples will be included for you
to copy when creating your own data schema, making your job a lot
easier. At the bottom of this Web page a whole Schema has been included,
from which parts have been included in the different sections throughout
this chapter. Refer to it if you would like to see how the whole Schema
works as one.

## Overview of Data Schemas

The data schema, all technicalities aside, is the data model with which
all the XML information is conveyed. It has a hierarchy structure
starting with a root element (to be explained later) and goes all the
way down to cover even the most minute detail of the model with detailed
steps in between. Data schemas have two main parts, the
`<i>`{=html}entities`</i>`{=html} and their
`<i>`{=html}relationships`</i>`{=html}. The entities contained in a data
schema represent objects from the model. They have unique identifiers,
attributes, and names for what kind of object they are. The
relationships in the schema represent the relationships between the
objects, simple enough. Relationships can be one to one, one to many,
many to many, recursive, and any other kind you could find in a data
model. Now we will begin to create our own data schema.

## Starting your schema the right way

All schemas begin the same way, no matter what type of objects they
represent. The first line in _every_ Schema is
this declaration:

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

`<small>`{=html}Exhibit 1: XML Declaration `</small>`{=html}

Exhibit 1 simply tells the browser or whatever file/program accessing
this schema that it is an XML file and uses the encoding structure
\"UTF-8\". You can copy this to use to start your own XML file. Next
comes the Namespace declaration:

``` xml
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified">
```

`<small>`{=html}Exhibit 2: Namespace Declaration `</small>`{=html}

Namespaces are basically dictionaries containing definitions of most of
the coding in the schema. For example, when creating a schema, if you
declare an object to be of type \"String\", the definition of the type
\"String\" is contained in the Namespace along with all of its
attributes. This is true for most of the code you write. If you have
made or seen other schemas, most of the code is prefaced by \"xsd:\". A
good example is something like \"xsd:sequence\" or \"xsd:complexType\".
sequence and complexType are both objects defined in the Namespace that
has been linked to the prefix \"xsd\". In fact, you could theoretically
name the default Namespace anything, as long as you referenced it the
same way throughout the Schema. The most common Namespace which contains
most of the XML objects is
`<i>`{=html}http://www.w3.org/2001/XMLSchema`</i>`{=html}. Now onto
Exhibit 2.

The first part lets any file/program know that this file is a schema.
Pretty easy to understand. Like the XML declaration, this is universal
to XML schemas and you can use it in yours. The second part is the
actual Namespace declaration; xmlns stands for **XML**
**N**ame**S**pace. This defines the Schema\'s default Namespace and is
usually the one given in the code. Again, I would recommend using this
code to start your Schemas. The last part is difficult to understand,
but here is a pretty detailed explanation. Using \"unqualified\" is most
applicable until you get to some really complicated code.

## Entities in general

Entities are basically the objects a Schema is created to represent. As
stated before, they have attributes and relationships. We will now go
much further into explaining exactly what they are and how to write code
for them.

There are two types of Entities: **simpleType** and **complexType**. A
simpleType object has one value associated with it. A string is a
perfect example of a simpleType object as it only contains the value of
the string. Most simpleTypes used will be defined in the default
Namespace; however, you can define your own simpleType at the bottom of
the Schema (this will be brought up in the restrictions section).
Because of this, the only objects you will most often need to include in
your Schema are complexTypes. A complexType is an object with more than
one attribute associated with it, and it may or may not have a child
elements attached to it. Here is an example of a complexType object:

``` xml
<xsd:complexType name="GenreType">
  <xsd:sequence>
    <xsd:element name="name" type="xsd:string"/>
    <xsd:element name="description" type="xsd:string"/>
    <xsd:element name="movie" type="MovieType" minOccurs="1" maxOccurs="unbounded"/>
  </xsd:sequence>
</xsd:complexType>
```

`<small>`{=html}Exhibit 3: The complexType Element `</small>`{=html}

This code begins with the declaration of a complexType and its name.
When other entities refer to it, such as a parent element, it will refer
to this name. The 2nd line begins the sequence of attributes and child
elements, which are all declared as an \"element\". The elements are
declared as elements with the 1st part of the line of code, and their
name to which other documents will refer is included as the \"name\" as
the 2nd part. After the first two declarations comes the \"type\"
declaration. Note that for the *name* and *description* elements their
type is \"xsd:string\" showing that the type string is defined in the
Namespace \"xsd\". For the *movie* element, the type is \"MovieType\",
and because there is no Namespace before \"MovieType\", it is assumed
that this type is included in this Schema. (it could refer to a type
defined in another Schema if the other Schema was included at the top of
the Schema. don\'t worry about that now) \"minOccurs\" and \"maxOccurs\"
represents the relationship between Genre\'s and MovieTypes.
\"minOccurs\" can be either 0 or an arbitrary number, depending only on
the data model. \"maxOccurs\" can be either 1 (a one to one
relationship), an arbitrary number (a one to many relationship), or
\"unbounded\" (a one to many relationship).

For each schema, there must be one `<b>`{=html}root
element`</b>`{=html}. This entity contains every other entity underneath
it in the hierarchy. For instance, when creating a schema to include a
list of movies, the root element would be something like MovieDatabase,
or maybe MovieCollection, just something that would logically contain
all the other objects (like genre, movie, actor, director, plotline,
etc.) It is always started with this line of code:
`<xsd:element name="xxx">`{=html} showing that it is the root element
and then goes on as a normal complexType. All other objects will begin
with either simpleType or complexType. Here is sample code for a
MovieDatabase root element:

``` xml
<xsd:element name="MovieDatabase">
     <xsd:complexType>
       <xsd:sequence>
         <xsd:element name="Genre" type="GenreType" minOccurs="1" maxOccurs="unbounded"/>
       </xsd:sequence>
     </xsd:complexType>
   </xsd:element>
```

`<small>`{=html}Exhibit 4: The Root Element `</small>`{=html}

This represents a MovieDatabase where the child element of MovieDatabase
is a Genre. From there it goes onto movie, etc. We will continue to use
this example help you better understand.

## The Parent / Child Relationship

The Parent / Child Relationship is a key topic in Data Schemas. It
represents the basic structure of the data model\'s hierarchy by clearly
laying out the top down configuration. Look at this piece of code which
shows how movies have actors associated with them:

``` xml
<xsd:complexType name="MovieType">
  <xsd:sequence>
    <xsd:element name="name" type="xsd:string"/>
    <xsd:element name="actor" type="ActorType" minOccurs="1" maxOccurs="unbounded"/>
  </xsd:sequence>
</xsd:complexType>

<xsd:complexType name="ActorType">
  <xsd:sequence>
    <xsd:element name="lname" type="xsd:string"/>
    <xsd:element name="fname" type="xsd:string"/>
  </xsd:sequence>
</xsd:complexType>
```

`<small>`{=html}Exhibit 5: The Parent/Child
Relationship`</small>`{=html}

Within each MovieType, there is an element named \"actor\" which is of
\"ActorType\". When the XML document is populated with information, the
surrounding tags for actor will be `<actor>`{=html}`</actor>`{=html} and
not `<ActorType>`{=html}`</ActorType>`{=html}. To keep your Schema
flowing smoothly and without error, the *type* field in the Parent
Element will always equal the *name* field in the declaration of the
complexType Child Element.

## Attributes and Restrictions

An attribute of an entity is a simpleType object in that it only
contains one value.
`<xsd:element name="lname" type="xsd:string"/>`{=html} is a good example
of an attribute. It is declared as an element, has a name associated
with it, and has a type declaration. Located in the appendix of this
chapter is a long list of simpleTypes built into the default Namespace.
Attributes are incredibly simple to use, until you try and restrict
them.

In some cases, certain data must abide by a standard to maintain data
integrity. An example of this would be a Social Security number or an
email address. If you have a database of email addresses that sends mass
emails to, you would need all of them to be valid addresses, or else
you\'d get tons of error messages each time you send out that mass
email. To avoid this problem, you can essentially take a known
simpleType and add a restriction to it to better suit your needs. Now
you can do this two ways, but one is simpler and better to use in Data
Schemas. You could edit the simpleType within its declaration in the
Parent Element, but it gets messy, and if another Schema wants to use
it, the code must be written again. The better way to do it is to list a
new type at the bottom of the Schema that edits a previously known
simpleType. Here is an example of this with a Social Security number:

``` xml
<xsd:simpleType name="emailaddressType">
  <xsd:restriction base="xsd:string">
    <xsd:pattern value="[^@]+@[^\.]+\..+"/>
  </xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="ssnType">
  <xsd:restriction base="xsd:string">
    <xsd:pattern value="\d{3}-\d{2}-\d{4}"/>
  </xsd:restriction>
</xsd:simpleType>
```

`<small>`{=html}Exhibit 6: Restriction on a simpleType `</small>`{=html}

This was included in the Schema below the last Child Element and before
the closing `</xsd:schema>`{=html}. The first line declares the
simpleType and gives it a name, \"ssnType\". You could name yours
anything you want, as long as you reference it correctly throughout the
Schema. By doing this, you can use this type anywhere in the Schema, or
anywhere in another Schema, provided the references are correct. The
second line lets the Schema know it is a restricted type and its base is
a string defined in the default Namespace. Basically, this type is a
string with a restriction on it, and the third line is the actual
restriction. It can be one of many types of restrictions, which are
listed in the Appendix of this chapter. This one happens to be of type
\"pattern\". A \"pattern\" means that only a certain sequence of
characters will be allowed in the XML document and is defined in the
`<i>`{=html}value`</i>`{=html} field. This particular one means three
digits, a hyphen, two digits, a hyphen, and four digits. To learn more
about how to use restrictions, follow this
link to the
W3 school\'s section on restrictions.

## Not of little import: Introducing the `<xsd:import>`{=html} tag

The `<xsd:import>`{=html} tag is used to import a schema document and
the namespace associated with the data types defined within the schema
document. This allows an XML schema document to reference a type library
using namespace names (prefixes). Let\'s take a closer look at a simple
XML instance document for a store that uses these multiple namespace
names:

> ``` xml
> <?xml version="1.0" encoding="UTF-8"?>
> <store:SimpleStore xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>   xsi:schemaLocation="http://www.opentourism.org/xmltext/SimpleStore.xsd"
>   xmlns:store="http://www.opentourism.org/xmltext/Store"
>   xmlns:MGR="http://www.opentourism.org/xmltext/CoreSchema">
>   <!-- Note the explicitly defined namespace declarations, the prefix store
>      represents data types defined in the
>      <code>http://www.opentourism.org/xmltext/Store.xml</code> namespace and the
>      prefix MGR represents data types defined in the
>      <code>http://www.opentourism.org/xmltext/CoreSchema</code> namespace.
>      Also, notice that there is no default namespace declaration – every element
>      and attribute must be associated with a namespace (we will see this is
>      necessary weh we examine the schema document)
> -->
>   <store:Store>
>     <MGR:Name xmlns:MGR=" http://www.opentourism.org/xmltext/CoreSchema ">
>       <MGR:FirstName>Michael</MGR:FirstName>
>       <MGR:MiddleNames>Jay</MGR:MiddleNames>
>       <MGR:LastName>Fox</MGR:LastName>
>     </MGR:Name>
>     <store:StoreName>The Gap</store:StoreName>
>     <store:StoreAddress>
>       <store:Street>86 Nowhere Ave.</store:Street>
>       <store:City>Los Angeles</store:City>
>       <store:State>CA</store:State>
>       <store:ZipCode>75309</store:ZipCode>
>     </store:StoreAddress>
>     <!-- More store information would go here. -->
>   </store:Store>
>   <!-- More stores would go here. -->
> </store:SimpleStore>
> ```

`<small>`{=html}Exhibit 7 XML Instance Document --
1`</small>`{=html}

Let\'s look at the schema document and see how the `<xsd:import>`{=html}
tag was used to import data types from a type library (external schema
document).

> ``` xml
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>   xmlns="http://www.opentourism.org/xmltext/Store.xml"
>   xmlns:MGR="http://www.opentourism.org/xmltext/CoreSchema"
>   targetNamespace="http://www.opentourism.org/xmltext/Store.xml" elementFormDefault="qualified">
>   <!-- The prefix MGR is bound to the following namespace name:
>           <code>http://www.opentourism.org/xmltext/CoreSchema</code>
>           The managerTypeLib.xsd schema document is imported by associating the
>           schema with the <code>http://www.opentourism.org/xmltext/CoreSchema</code>
>           namespace name, which was bound to the MGR prefix.
>           The elementFormDefault attribute has the value ‘qualified' indicating that
>           an XML instance document must use qualified names for every element(default
>           namespace can not be used)
> -->
>   <!-- The target namespace and default namespace are the same  -->
>   <xsd:import namespace="http://www.opentourism.org/xmltext/CoreSchema"
>     schemaLocation="ManagerTypeLib.xsd"/>
>   <xsd:element name="SimpleStore">
>     <xsd:complexType>
>       <xsd:sequence>
>         <xsd:element name="Store" type="StoreType" maxOccurs="unbounded"/>
>       </xsd:sequence>
>     </xsd:complexType>
>   </xsd:element>
>   <xsd:complexType name="StoreType">
>     <xsd:sequence>
>       <xsd:element ref="MGR:Name"/>
>       <xsd:element name="StoreName" type="xsd:string"/>
>       <xsd:element name="StoreAddress" type="StoreAddressType"/>
>     </xsd:sequence>
>   </xsd:complexType>
>   <xsd:complexType name="StoreAddressType">
>     <xsd:sequence>
>       <xsd:element name="Street" type="xsd:string"/>
>       <xsd:element name="City" type="xsd:string"/>
>       <xsd:element name="State" type="xsd:string"/>
>       <xsd:element name="ZipCode" type="xsd:string"/>
>     </xsd:sequence>
>   </xsd:complexType>
> </xsd:schema>
> ```

`<small>`{=html}Exhibit 8: XML Schema
\[<http://www.opentourism.org/xmltext/SimpleStore.xsd>`</small>`{=html}

Like the include tag and the redefine tag, the import tag is another
means of incorporating any data types from an external schema document
into another schema document and must occur before any element or
attribute declarations. These mechanisms are important when XML schemas
are modularized and type libraries are being maintained and used in
multiple schema documents.

## When the whole is greater than the sum of its parts: Schema Modularization

Now that we have covered all three methods of incorporating external XML
schemas, let's consider the importance of these mechanisms. As is
typical with most programming code, redundancy is frowned upon; this is
true for custom data type definitions as well. If a custom data type
already exists that can be applied to an element in your schema
document, does it not make sense to use this data type rather than
create it again within your new schema document? Moreover, if you know
that a single data type can be reused for several applications, should
you not have a method for referencing that data type when you need it?

The idea behind modular schemas is to examine what your schema does,
determine what data types are frequently used in one form or another and
develop a type library. As your needs for more complex schemas increase
you can continue to add to your library, reuse data types in your type
library, and redefine those data types as needed. An example of this
reuse would be a schema for customer information -- different
departments would use different schemas as they would need only partial
customer information. However most, if not all, departments would need
some specific customer information, like name and contact information,
which could be incorporated in the individual departmental schema
documents.

Schema modularization is a "best practice". By maintaining a type
library and reusing and redefining types in the type library, you can
help ensure that your XML schema documents don\'t become overwhelming
and difficult to read. Readability is important, because you may not be
the only one using these schemas, and it is important that others can
easily understand your schema documents.

## "Choose, but choose wisely...": Schema alternatives

Thus far in this book we have only discussed XML schemas as defined by
the World Wide Web Consortium (W3C). Yet there are other methods of
defining the data contained within an XML instanced document, but we
will only mention the two most popular and well known alternatives:
Document Type Definition (DTD) and Relax NG Schema.

We will cover DTDs in the next chapter. Relax NG schema is a newer and
has many of the same features that W3C XML schema have; Relax NG also
claims to be simpler, and easier to learn, but this is very subjective.
For more about Relax NG, visit: <http://www.relaxng.org/>

## Appendix

First is the full Schema used in the examples throughout this chapter:

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

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="unqualified">

   <xsd:element name="MovieDatabase">
     <xsd:complexType>
       <xsd:sequence>
         <xsd:element name="Genre" type="GenreType" minOccurs="1" maxOccurs="unbounded"/>
       </xsd:sequence>
     </xsd:complexType>
   </xsd:element>

     <xsd:complexType name="GenreType">
       <xsd:sequence>
         <xsd:element name="name" type="xsd:string"/>
         <xsd:element name="description" type="xsd:string"/>
         <xsd:element name="movie" type="MovieType" minOccurs="1" maxOccurs="unbounded"/>
       </xsd:sequence>
     </xsd:complexType>

     <xsd:complexType name="MovieType">
       <xsd:sequence>
         <xsd:element name="name" type="xsd:string"/>
         <xsd:element name="rating" type="xsd:string"/>
         <xsd:element name="director" type="xsd:string"/>
         <xsd:element name="writer" type="xsd:string"/>
         <xsd:element name="year" type="xsd:int"/>
         <xsd:element name="tagline" type="xsd:string"/>
         <xsd:element name="actor" type="ActorType" minOccurs="1" maxOccurs="unbounded"/>
       </xsd:sequence>
     </xsd:complexType>

     <xsd:complexType name="ActorType">
       <xsd:sequence>
         <xsd:element name="lname" type="xsd:string"/>
         <xsd:element name="fname" type="xsd:string"/>
         <xsd:element name="gender" type="xsd:string"/>
         <xsd:element name="bday" type="xsd:string"/>
         <xsd:element name="birthplace" type="xsd:string"/>
         <xsd:element name="ssn" type="ssnType"/>
       </xsd:sequence>
     </xsd:complexType>

     <xsd:simpleType name="ssnType">
       <xsd:restriction base="xsd:string">
         <xsd:pattern value="\d{3}-\d{2}-\d{4}"/>
       </xsd:restriction>
   </xsd:simpleType>

</xsd:schema>
```

It's time to go back to the beginning...and review all of the schema
data types, elements, and attributes that we have covered thus far (and
maybe a few that we have not). The following tables will detail the XML
data types, elements and attributes that can be used in an XML Schema.

```{=html}
<h4 align="center">
```
Primitive Types

```{=html}
</h4>
```
This is a table with all the primitive types the attributes in your
schema can be.

  ------------------------ -------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------------------------------------
  **Type**                 **Syntax**                                                                 **Legal value example**                                                                                **Constraining facets**
  xsd:anyURI               \<xsd:element name = "url" type = "xsd:anyURI" /\>                         <http://www.w3.com>                                                                                length, minLength, maxLength, pattern, enumeration, whitespace
  xsd:boolean              \<xsd:element name = "hasChildren" type = "xsd:boolean" /\>                true `<em>`{=html}or `</em>`{=html} false `<em>`{=html}or `</em>`{=html} 1 `<em>`{=html}or `</em>`{=html} 0   pattern and whitespace
  xsd:byte                 \<xsd:element name = "stdDev" type = "xsd:byte" /\>                        -128 `<em>`{=html}through `</em>`{=html} 127                                                                  length, minInclusive, maxInclusive, minExclusive, maxExclusive, pattern, enumeration, whitespace, and totalDigits
  xsd:date                 \<xsd:element name = "dateEst" type = "xsd:date" /\>                       2004-03-15                                                                                minInclusive, maxInclusive, minExclusive, maxExclusive, pattern, enumeration, and whitespace
  xsd:dateTime             \<xsd:element name = "xMas" type = "xsd:dateTime" /\>                      2003-12-25T08:30:00                                                                                minInclusive, maxInclusive, minExclusive, maxExclusive, pattern, enumeration, and whitespace
  xsd:decimal              \<xsd:element name = "pi" type = "xsd:decimal" /\>                         3.1415292                                                                                minInclusive, maxInclusive, minExclusive, maxExclusive, pattern, enumeration,   whitespace, fractionDigits, and totalDigits
  xsd:double               \<xsd:element name = "pi" type = "xsd:double" /\>                          3.1415292 `<em>`{=html}or `</em>`{=html} INF `<em>`{=html}or `</em>`{=html} NaN                               minInclusive, maxInclusive, minExclusive, maxExclusive, pattern, enumeration,   and whitespace
  xsd:duration             \<xsd:element name = "MITDuration" type = "xsd:duration" /\>               P8M3DT7H33M2S
  xsd:float                \<xsd:element name = "pi" type = "xsd:float" /\>                           3.1415292 `<em>`{=html}or `</em>`{=html} INF `<em>`{=html}or `</em>`{=html} NaN                               minInclusive, maxInclusive, minExclusive, maxExclusive, pattern, enumeration,   and whitespace
  xsd:gDay                 \<xsd:element name = "dayOfMonth" type = "xsd:gDay" /\>                    \-\--11                                                                                minInclusive, maxInclusive, minExclusive, maxExclusive, pattern, enumeration,   and whitespace
  xsd:gMonth               \<xsd:element name = "monthOfYear" type = "xsd:gMonth" /\>                 \--02\--                                                                                minInclusive, maxInclusive, minExclusive, maxExclusive, pattern, enumeration,   and whitespace
  xsd:gMonthDay            \<xsd:element name = "valentine" type = "xsd:gMonthDay" /\>                \--02-14                                                                                minInclusive, maxInclusive, minExclusive, maxExclusive, pattern, enumeration,   and whitespace
  xsd:gYear                \<xsd:element name = "year" type = "xsd:gYear" /\>                         1999                                                                                minInclusive, maxInclusive, minExclusive, maxExclusive, pattern, enumeration,   and whitespace
  xsd:gYearMonth           \<xsd:element name = "birthday" type = "xsd:gYearMonth" /\>                1972-08                                                                                minInclusive, maxInclusive, minExclusive, maxExclusive, pattern, enumeration,   and whitespace
  xsd:ID                   \<xsd:attribute name=\"id\" type=\"xsd:ID\"/\>                             id-102                                                                                length, minLength, maxLength, pattern, enumeration,   and whitespace
  xsd:IDREF                \<xsd:attribute name=\"version\" type=\"xsd:IDREF\"/\>                     id-102                                                                                length, minLength, maxLength, pattern, enumeration,   and whitespace
  xsd:IDREFS               \<xsd:attribute name=\"versionList\" type=\"xsd:IDREFS\"/\>                id-102 id-103 id-100                                                                                length, minLength, maxLength, pattern, enumeration,   and whitespace
  xsd:int                  \<xsd:element name = "age" type = "xsd:int" /\>                            77                                                                                minInclusive, maxInclusive, minExclusive, maxExclusive, pattern, enumeration, whitespace, and totalDigits
  xsd:integer              \<xsd:element name = "age" type = "xsd:integer" /\>                        77                                                                                minInclusive, maxInclusive, minExclusive, maxExclusive, pattern, enumeration,   and whitespace
  xsd:long                 \<xsd:element name = "cannelNumber" type = "xsd:int" /\>                   214                                                                                minInclusive, maxInclusive, minExclusive, maxExclusive, pattern, enumeration,   and whitespace
  xsd:negativeInteger      \<xsd:element name = "belowZero" type = "xsd:negativeInteger" /\>          -123                                                                                minInclusive, maxInclusive, minExclusive, maxExclusive, pattern, enumeration,   whitespace, and totalDigits
  xsd:nonNegativeInteger   \<xsd:element name = "numOfchildren" type = "xsd:nonNegativeInteger" /\>   2                                                                                minInclusive, maxInclusive, minExclusive, maxExclusive, pattern, enumeration,   whitespace, and totalDigits
  xsd:nonPositiveInteger   \<xsd:element name = "debit" type = "xsd:nonPositiveInteger" /\>           0                                                                                minInclusive, maxInclusive, minExclusive, maxExclusive, pattern, enumeration,   whitespace, and totalDigits
  xsd:positiveInteger      \<xsd:element name = "credit" type = "xsd:positiveInteger" /\>             500                                                                                minInclusive, maxInclusive, minExclusive, maxExclusive, pattern, enumeration,   whitespace, and totalDigits
  xsd:short                \<xsd:element name = "numOfpages" type = "xsd:short" /\>                   476                                                                                minInclusive, maxInclusive, minExclusive, maxExclusive, pattern, enumeration,   whitespace, and totalDigits
  xsd:string               \<xsd:element name = "name" type = "xsd:string" /\>                        Joeseph                                                                                length, minLength, maxLength, pattern, enumeration,   whitespace, and totalDigits
  xsd:time                 \<xsd:element name = "credit" type = "xsd:time" /\>                        13:02:00                                                                                minInclusive, maxInclusive, minExclusive, maxExclusive, pattern, enumeration,   and whitespace,
  ------------------------ -------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------------------------------------

```{=html}
<h4 align="center">
```
Schema Elements\
`<span style="font-size:x-small;">`{=html} ( from
<http://www.w3schools.com/schema/schema_elements_ref.asp>
)`</span>`{=html}

```{=html}
</h4>
```
Here is a list of all the elements which can be included in your
schemas.

+---+----+
| ` | `< |
| < | st |
| s | ro |
| t | ng |
| r | >` |
| o | {= |
| n | ht |
| g | ml |
| > | }E |
| ` | xp |
| { | la |
| = | na |
| h | ti |
| t | on |
| m | `< |
| l | /s |
| } | tr |
| E | on |
| l | g> |
| e | `{ |
| m | =h |
| e | tm |
| n | l} |
| t |    |
| ` |    |
| < |    |
| / |    |
| s |    |
| t |    |
| r |    |
| o |    |
| n |    |
| g |    |
| > |    |
| ` |    |
| { |    |
| = |    |
| h |    |
| t |    |
| m |    |
| l |    |
| } |    |
+---+----+
| a | S  |
| l | pe |
| l | ci |
|   | fi |
|   | es |
|   | th |
|   | at |
|   | t  |
|   | he |
|   | c  |
|   | hi |
|   | ld |
|   | el |
|   | em |
|   | en |
|   | ts |
|   | c  |
|   | an |
|   | ap |
|   | pe |
|   | ar |
|   | in |
|   | a  |
|   | ny |
|   | or |
|   | de |
|   | r. |
|   | Ea |
|   | ch |
|   | c  |
|   | hi |
|   | ld |
|   | e  |
|   | le |
|   | me |
|   | nt |
|   | c  |
|   | an |
|   | o  |
|   | cc |
|   | ur |
|   | 0  |
|   | or |
|   | 1  |
|   | ti |
|   | me |
+---+----+
| a | S  |
| n | pe |
| n | ci |
| o | fi |
| t | es |
| a | t  |
| t | he |
| i | t  |
| o | op |
| n | -l |
|   | ev |
|   | el |
|   | e  |
|   | le |
|   | me |
|   | nt |
|   | f  |
|   | or |
|   | sc |
|   | he |
|   | ma |
|   | co |
|   | mm |
|   | en |
|   | ts |
+---+----+
| a | E  |
| n | na |
| y | bl |
|   | es |
|   | t  |
|   | he |
|   | au |
|   | th |
|   | or |
|   | to |
|   | ex |
|   | te |
|   | nd |
|   | t  |
|   | he |
|   | X  |
|   | ML |
|   | do |
|   | cu |
|   | me |
|   | nt |
|   | wi |
|   | th |
|   | el |
|   | em |
|   | en |
|   | ts |
|   | n  |
|   | ot |
|   | s  |
|   | pe |
|   | ci |
|   | fi |
|   | ed |
|   | by |
|   | t  |
|   | he |
|   | sc |
|   | he |
|   | ma |
+---+----+
| a | E  |
| n | na |
| y | bl |
| A | es |
| t | t  |
| t | he |
| r | au |
| i | th |
| b | or |
| u | to |
| t | ex |
| e | te |
|   | nd |
|   | t  |
|   | he |
|   | X  |
|   | ML |
|   | do |
|   | cu |
|   | me |
|   | nt |
|   | wi |
|   | th |
|   | at |
|   | tr |
|   | ib |
|   | ut |
|   | es |
|   | n  |
|   | ot |
|   | s  |
|   | pe |
|   | ci |
|   | fi |
|   | ed |
|   | by |
|   | t  |
|   | he |
|   | sc |
|   | he |
|   | ma |
+---+----+
| a | S  |
| p | pe |
| p | ci |
| I | fi |
| n | es |
| f | i  |
| o | nf |
|   | or |
|   | ma |
|   | ti |
|   | on |
|   | to |
|   | be |
|   | us |
|   | ed |
|   | by |
|   | t  |
|   | he |
|   | a  |
|   | pp |
|   | li |
|   | ca |
|   | ti |
|   | on |
|   | (  |
|   | mu |
|   | st |
|   | go |
|   | in |
|   | si |
|   | de |
|   | a  |
|   | nn |
|   | ot |
|   | at |
|   | io |
|   | n) |
+---+----+
| a | D  |
| t | ef |
| t | in |
| r | es |
| i | an |
| b | a  |
| u | tt |
| t | ri |
| e | bu |
|   | te |
+---+----+
| a | D  |
| t | ef |
| t | in |
| r | es |
| i | an |
| b | a  |
| u | tt |
| t | ri |
| e | bu |
| G | te |
| r | g  |
| o | ro |
| u | up |
| p | to |
|   | be |
|   | us |
|   | ed |
|   | in |
|   | c  |
|   | om |
|   | pl |
|   | ex |
|   | ty |
|   | pe |
|   | d  |
|   | ef |
|   | in |
|   | it |
|   | io |
|   | ns |
+---+----+
| c | Al |
| h | lo |
| o | ws |
| i | on |
| c | ly |
| e | o  |
|   | ne |
|   | of |
|   | t  |
|   | he |
|   | el |
|   | em |
|   | en |
|   | ts |
|   | c  |
|   | on |
|   | ta |
|   | in |
|   | ed |
|   | in |
|   | t  |
|   | he |
|   | \< |
|   | ch |
|   | oi |
|   | ce |
|   | \> |
|   | d  |
|   | ec |
|   | la |
|   | ra |
|   | ti |
|   | on |
|   | to |
|   | be |
|   | p  |
|   | re |
|   | se |
|   | nt |
|   | wi |
|   | th |
|   | in |
|   | t  |
|   | he |
|   | co |
|   | nt |
|   | ai |
|   | ni |
|   | ng |
|   | e  |
|   | le |
|   | me |
|   | nt |
+---+----+
| c | D  |
| o | ef |
| m | in |
| p | es |
| l | ex |
| e | te |
| x | ns |
| C | io |
| o | ns |
| n | or |
| t | re |
| e | st |
| n | ri |
| t | ct |
|   | io |
|   | ns |
|   | on |
|   | a  |
|   | c  |
|   | om |
|   | pl |
|   | ex |
|   | ty |
|   | pe |
|   | th |
|   | at |
|   | co |
|   | nt |
|   | ai |
|   | ns |
|   | m  |
|   | ix |
|   | ed |
|   | c  |
|   | on |
|   | te |
|   | nt |
|   | or |
|   | el |
|   | em |
|   | en |
|   | ts |
|   | on |
|   | ly |
+---+----+
| c | D  |
| o | ef |
| m | in |
| p | es |
| l | a  |
| e | c  |
| x | om |
| T | pl |
| y | ex |
| p | ty |
| e | pe |
|   | e  |
|   | le |
|   | me |
|   | nt |
+---+----+
| d | D  |
| o | ef |
| c | in |
| u | es |
| m | te |
| e | xt |
| n | co |
| t | mm |
| a | en |
| t | ts |
| i | in |
| o | a  |
| n | sc |
|   | he |
|   | ma |
|   | (  |
|   | mu |
|   | st |
|   | go |
|   | in |
|   | si |
|   | de |
|   | a  |
|   | nn |
|   | ot |
|   | at |
|   | io |
|   | n) |
+---+----+
| e | D  |
| l | ef |
| e | in |
| m | es |
| e | an |
| n | e  |
| t | le |
|   | me |
|   | nt |
+---+----+
| e | E  |
| x | xt |
| t | en |
| e | ds |
| n | an |
| s | ex |
| i | is |
| o | ti |
| n | ng |
|   | si |
|   | mp |
|   | le |
|   | Ty |
|   | pe |
|   | or |
|   | c  |
|   | om |
|   | pl |
|   | ex |
|   | Ty |
|   | pe |
|   | e  |
|   | le |
|   | me |
|   | nt |
+---+----+
| f | S  |
| i | pe |
| e | ci |
| l | fi |
| d | es |
|   | an |
|   | X  |
|   | Pa |
|   | th |
|   | ex |
|   | pr |
|   | es |
|   | si |
|   | on |
|   | th |
|   | at |
|   | s  |
|   | pe |
|   | ci |
|   | fi |
|   | es |
|   | t  |
|   | he |
|   | v  |
|   | al |
|   | ue |
|   | us |
|   | ed |
|   | to |
|   | de |
|   | fi |
|   | ne |
|   | an |
|   | id |
|   | en |
|   | ti |
|   | ty |
|   | co |
|   | ns |
|   | tr |
|   | ai |
|   | nt |
+---+----+
| g | D  |
| r | ef |
| o | in |
| u | es |
| p | a  |
|   | g  |
|   | ro |
|   | up |
|   | of |
|   | el |
|   | em |
|   | en |
|   | ts |
|   | to |
|   | be |
|   | us |
|   | ed |
|   | in |
|   | c  |
|   | om |
|   | pl |
|   | ex |
|   | ty |
|   | pe |
|   | d  |
|   | ef |
|   | in |
|   | it |
|   | io |
|   | ns |
+---+----+
| i | Ad |
| m | ds |
| p | mu |
| o | lt |
| r | ip |
| t | le |
|   | s  |
|   | ch |
|   | em |
|   | as |
|   | wi |
|   | th |
|   | d  |
|   | if |
|   | fe |
|   | re |
|   | nt |
|   | ta |
|   | rg |
|   | et |
|   | n  |
|   | am |
|   | es |
|   | pa |
|   | ce |
|   | to |
|   | a  |
|   | do |
|   | cu |
|   | me |
|   | nt |
+---+----+
| i | Ad |
| n | ds |
| c | mu |
| l | lt |
| u | ip |
| d | le |
| e | s  |
|   | ch |
|   | em |
|   | as |
|   | wi |
|   | th |
|   | t  |
|   | he |
|   | sa |
|   | me |
|   | ta |
|   | rg |
|   | et |
|   | n  |
|   | am |
|   | es |
|   | pa |
|   | ce |
|   | to |
|   | a  |
|   | do |
|   | cu |
|   | me |
|   | nt |
+---+----+
| k | S  |
| e | pe |
| y | ci |
|   | fi |
|   | es |
|   | an |
|   | a  |
|   | tt |
|   | ri |
|   | bu |
|   | te |
|   | or |
|   | e  |
|   | le |
|   | me |
|   | nt |
|   | v  |
|   | al |
|   | ue |
|   | as |
|   | a  |
|   | k  |
|   | ey |
|   | (u |
|   | ni |
|   | qu |
|   | e, |
|   | n  |
|   | on |
|   | -n |
|   | ul |
|   | la |
|   | bl |
|   | e, |
|   | a  |
|   | nd |
|   | al |
|   | wa |
|   | ys |
|   | pr |
|   | es |
|   | en |
|   | t) |
|   | wi |
|   | th |
|   | in |
|   | t  |
|   | he |
|   | co |
|   | nt |
|   | ai |
|   | ni |
|   | ng |
|   | e  |
|   | le |
|   | me |
|   | nt |
|   | in |
|   | an |
|   | in |
|   | st |
|   | an |
|   | ce |
|   | do |
|   | cu |
|   | me |
|   | nt |
+---+----+
| k | S  |
| e | pe |
| y | ci |
| r | fi |
| e | es |
| f | th |
|   | at |
|   | an |
|   | a  |
|   | tt |
|   | ri |
|   | bu |
|   | te |
|   | or |
|   | e  |
|   | le |
|   | me |
|   | nt |
|   | v  |
|   | al |
|   | ue |
|   | co |
|   | rr |
|   | es |
|   | po |
|   | nd |
|   | to |
|   | t  |
|   | ho |
|   | se |
|   | of |
|   | t  |
|   | he |
|   | s  |
|   | pe |
|   | ci |
|   | fi |
|   | ed |
|   | k  |
|   | ey |
|   | or |
|   | un |
|   | iq |
|   | ue |
|   | e  |
|   | le |
|   | me |
|   | nt |
+---+----+
| l | D  |
| i | ef |
| s | in |
| t | es |
|   | a  |
|   | si |
|   | mp |
|   | le |
|   | ty |
|   | pe |
|   | e  |
|   | le |
|   | me |
|   | nt |
|   | as |
|   | a  |
|   | li |
|   | st |
|   | of |
|   | va |
|   | lu |
|   | es |
+---+----+
| n | D  |
| o | es |
| t | cr |
| a | ib |
| t | es |
| i | t  |
| o | he |
| n | fo |
|   | rm |
|   | at |
|   | of |
|   | n  |
|   | on |
|   | -X |
|   | ML |
|   | da |
|   | ta |
|   | wi |
|   | th |
|   | in |
|   | an |
|   | X  |
|   | ML |
|   | do |
|   | cu |
|   | me |
|   | nt |
+---+----+
| r | R  |
| e | ed |
| d | ef |
| e | in |
| f | es |
| i | si |
| n | mp |
| e | le |
|   | a  |
|   | nd |
|   | c  |
|   | om |
|   | pl |
|   | ex |
|   | ty |
|   | pe |
|   | s, |
|   | g  |
|   | ro |
|   | up |
|   | s, |
|   | a  |
|   | nd |
|   | a  |
|   | tt |
|   | ri |
|   | bu |
|   | te |
|   | gr |
|   | ou |
|   | ps |
|   | fr |
|   | om |
|   | an |
|   | ex |
|   | te |
|   | rn |
|   | al |
|   | sc |
|   | he |
|   | ma |
+---+----+
| r | D  |
| e | ef |
| s | in |
| t | es |
| r | re |
| i | st |
| c | ri |
| t | ct |
| i | io |
| o | ns |
| n | on |
|   | a  |
|   | s  |
|   | im |
|   | pl |
|   | eT |
|   | yp |
|   | e, |
|   | si |
|   | mp |
|   | le |
|   | Co |
|   | nt |
|   | en |
|   | t, |
|   | or |
|   | a  |
|   | co |
|   | mp |
|   | le |
|   | xC |
|   | on |
|   | te |
|   | nt |
+---+----+
| s | D  |
| c | ef |
| h | in |
| e | es |
| m | t  |
| a | he |
|   | ro |
|   | ot |
|   | e  |
|   | le |
|   | me |
|   | nt |
|   | of |
|   | a  |
|   | sc |
|   | he |
|   | ma |
+---+----+
| s | S  |
| e | pe |
| l | ci |
| e | fi |
| c | es |
| t | an |
| o | X  |
| r | Pa |
|   | th |
|   | ex |
|   | pr |
|   | es |
|   | si |
|   | on |
|   | th |
|   | at |
|   | s  |
|   | el |
|   | ec |
|   | ts |
|   | a  |
|   | s  |
|   | et |
|   | of |
|   | el |
|   | em |
|   | en |
|   | ts |
|   | f  |
|   | or |
|   | an |
|   | id |
|   | en |
|   | ti |
|   | ty |
|   | co |
|   | ns |
|   | tr |
|   | ai |
|   | nt |
+---+----+
| s | S  |
| e | pe |
| q | ci |
| u | fi |
| e | es |
| n | th |
| c | at |
| e | t  |
|   | he |
|   | c  |
|   | hi |
|   | ld |
|   | el |
|   | em |
|   | en |
|   | ts |
|   | mu |
|   | st |
|   | ap |
|   | pe |
|   | ar |
|   | in |
|   | a  |
|   | s  |
|   | eq |
|   | ue |
|   | nc |
|   | e. |
|   | Ea |
|   | ch |
|   | c  |
|   | hi |
|   | ld |
|   | e  |
|   | le |
|   | me |
|   | nt |
|   | c  |
|   | an |
|   | o  |
|   | cc |
|   | ur |
|   | fr |
|   | om |
|   | 0  |
|   | to |
|   | a  |
|   | ny |
|   | nu |
|   | mb |
|   | er |
|   | of |
|   | t  |
|   | im |
|   | es |
+---+----+
| s | Co |
| i | nt |
| m | ai |
| p | ns |
| l | ex |
| e | te |
| C | ns |
| o | io |
| n | ns |
| t | or |
| e | re |
| n | st |
| t | ri |
|   | ct |
|   | io |
|   | ns |
|   | on |
|   | a  |
|   | t  |
|   | ex |
|   | t- |
|   | on |
|   | ly |
|   | c  |
|   | om |
|   | pl |
|   | ex |
|   | ty |
|   | pe |
|   | or |
|   | on |
|   | a  |
|   | si |
|   | mp |
|   | le |
|   | ty |
|   | pe |
|   | as |
|   | c  |
|   | on |
|   | te |
|   | nt |
|   | a  |
|   | nd |
|   | co |
|   | nt |
|   | ai |
|   | ns |
|   | no |
|   | el |
|   | em |
|   | en |
|   | ts |
+---+----+
| s | D  |
| i | ef |
| m | in |
| p | es |
| l | a  |
| e | si |
| T | mp |
| y | le |
| p | ty |
| e | pe |
|   | a  |
|   | nd |
|   | s  |
|   | pe |
|   | ci |
|   | fi |
|   | es |
|   | t  |
|   | he |
|   | c  |
|   | on |
|   | st |
|   | ra |
|   | in |
|   | ts |
|   | a  |
|   | nd |
|   | i  |
|   | nf |
|   | or |
|   | ma |
|   | ti |
|   | on |
|   | a  |
|   | bo |
|   | ut |
|   | t  |
|   | he |
|   | va |
|   | lu |
|   | es |
|   | of |
|   | at |
|   | tr |
|   | ib |
|   | ut |
|   | es |
|   | or |
|   | t  |
|   | ex |
|   | t- |
|   | on |
|   | ly |
|   | el |
|   | em |
|   | en |
|   | ts |
+---+----+
| u | D  |
| n | ef |
| i | in |
| o | es |
| n | a  |
|   | si |
|   | mp |
|   | le |
|   | ty |
|   | pe |
|   | as |
|   | a  |
|   | co |
|   | ll |
|   | ec |
|   | ti |
|   | on |
|   | (  |
|   | un |
|   | io |
|   | n) |
|   | of |
|   | va |
|   | lu |
|   | es |
|   | fr |
|   | om |
|   | s  |
|   | pe |
|   | ci |
|   | fi |
|   | ed |
|   | si |
|   | mp |
|   | le |
|   | da |
|   | ta |
|   | t  |
|   | yp |
|   | es |
+---+----+
| u | D  |
| n | ef |
| i | in |
| q | es |
| u | th |
| e | at |
|   | an |
|   | e  |
|   | le |
|   | me |
|   | nt |
|   | or |
|   | an |
|   | a  |
|   | tt |
|   | ri |
|   | bu |
|   | te |
|   | v  |
|   | al |
|   | ue |
|   | mu |
|   | st |
|   | be |
|   | un |
|   | iq |
|   | ue |
|   | wi |
|   | th |
|   | in |
|   | t  |
|   | he |
|   | s  |
|   | co |
|   | pe |
+---+----+

```{=html}
<h4 align="center">
```
Schema Restrictions and Facets for data types\
`<span style="font-size:x-small;">`{=html}( from
<http://www.w3schools.com/schema/schema_elements_ref.asp>
)`</span>`{=html}

```{=html}
</h4>
```
Here is a list of all the types of restrictions which can be included in
your schema.

  ------------------------------------------------ ---------------------------------------------------------------------------------------------------------
  `<strong>`{=html}Constraint `</strong>`{=html}   `<strong>`{=html}Description `</strong>`{=html}
  enumeration                                      Defines a list of acceptable values
  fractionDigits                                   Specifies the maximum number of decimal places allowed. Must be equal to or greater than zero
  length                                           Specifies the exact number of characters or list items allowed. Must be equal to or greater than zero
  maxExclusive                                     Specifies the upper bounds for numeric values (the value must be less than this value)
  maxInclusive                                     Specifies the upper bounds for numeric values (the value must be less than or equal to this value)
  maxLength                                        Specifies the maximum number of characters or list items allowed. Must be equal to or greater than zero
  minExclusive                                     Specifies the lower bounds for numeric values (the value must be greater than this value)
  minInclusive                                     Specifies the lower bounds for numeric values (the value must be greater than or equal to this value)
  minLength                                        Specifies the minimum number of characters or list items allowed. Must be equal to or greater than zero
  pattern                                          Defines the exact sequence of characters that are acceptable
  totalDigits                                      Specifies the exact number of digits allowed. Must be greater than zero
  whiteSpace                                       Specifies how white space (line feeds, tabs, spaces, and carriage returns) are handled
  ------------------------------------------------ ---------------------------------------------------------------------------------------------------------

```{=html}
<h4 align="center">
```
Regex\

```{=html}
</h4>
```
Special regular expression (regex) language can be used to construct a
pattern. The regex language in XML Schema is based on Perl\'s regular
expression language. The following are some common notations:

  --------------- -----------------------------------------------------------------
  . (the period   for any character at all
  \\d             for any digit
  \\D             for any non-digit
  \\w             for any word (alphanumeric) character
  \\W             for any non-word character (i.e. -, +, =)
  \\s             for any white space (including space, tab, newline, and return)
  \\S             for any character that is not white space
  x\*             to have zero or more x\'s
  (xy)\*          to have zero or more xy\'s
  x+              repetition of the x, at least once
  x?              to have one or zero x\'s
  (xy)?           To have one or no xy\'s
  \[abc\]         to include one of a group of values
  \[0-9\]         to include the range of values from 0 to 9
  x{5}            to have exactly 5 x\'s (in a row)
  x{5,}           to have at least 5 x\'s (in a row)
  x{5,8}          at least 5 but at most 8 x\'s (in a row)
  (xyz){2}        to have exactly 2 xyz\'s (in a row)
  --------------- -----------------------------------------------------------------

+----------------------------------------------------------------------+
| For example, the pattern for validating a Social Security Number is  |
| \\d{3}-\\d{2}-\\d{4}                                                 |
|                                                                      |
| The schema code for **emailAddressType** is                          |
| \\w+\\W\*\\w\*@{1}\\w+\\W\*\\w+.\\w+.\*\\w\*                         |
+----------------------------------------------------------------------+
| \[w+\]                                                               |
+----------------------------------------------------------------------+
| \[W\*\]                                                              |
+----------------------------------------------------------------------+
| \[w\*@{1}\]                                                          |
+----------------------------------------------------------------------+
| \[w+\]                                                               |
+----------------------------------------------------------------------+
| \[W\*\]                                                              |
+----------------------------------------------------------------------+
| \[w+.\]                                                              |
+----------------------------------------------------------------------+
| \[w+.\*\]                                                            |
+----------------------------------------------------------------------+
| \[w\*\]                                                              |
+----------------------------------------------------------------------+
| email-address: **answer-my@mail_please.opentourism.org**             |
+----------------------------------------------------------------------+

```{=html}
<h4 align="center">
```
Instance Document Attributes\
`<span style="font-size:small;">`{=html}These attributes do NOT need to
be declared within the schemas`</span>`{=html}

```{=html}
</h4>
```
+----------------------+----------------------+----------------------+
| **Attribute**        | **Explanation**      | **Example**          |
+----------------------+----------------------+----------------------+
| xsi:nil              | Indicates that a     | \<full_name          |
|                      | certain element does | xmlns:xsi=           |
|                      | not have a value or  | "http                |
|                      | that the value is    | ://www.w3.org/2001/X |
|                      | unknown.   The       | MLSchema-instance"\> |
|                      | element must be set  |                      |
|                      | to nillable inside   | \<first_name\>Mad    |
|                      | the schema           | onna\</first_name\>\ |
|                      | document:\           | \<last_name          |
|                      | \<xsd:element        | xsi:nil="true"/\>    |
|                      | name="last_name"     | \</full_name\>       |
|                      | type="xsd:string"    |                      |
|                      | nillable=true"/\>    |                      |
+----------------------+----------------------+----------------------+
| xsi:noNam            | Locates the schema   | \<radio              |
| espaceSchemaLocation | for elements that    | xsi:noName           |
|                      | are not in any       | spaceSchemaLocation= |
|                      | namespace            | "http:/              |
|                      |                      | /www.opentourism.org |
|                      |                      | /xmtext/radio.xsd"\> |
|                      |                      | \


# XML - Managing Data Exchange/DTD

A **D**ocument **T**ype **D**efinition is a file that links to an XML
page. It controls what must or can be displayed, what attributes and
their values must/can have and how the XML file should look like. XHTML,
HTML and other markup languages use DTDs to validate their documents.
**Note**: Web browsers accept bad markup in HTML.

## Uses OF DTDs

DTDs are used to store large amounts of data in a custom markup language
that can be used for a specific program or organization. Like schemas
they can have elements, attributes and entities. The only difference is
how it is displayed.

## Prologue

Like in a schema, a DTD has a prolog. It is one line of text.

``` XML
<?xml version="1.0" encoding="UTF-8"?>
```

The question mark is to tell the computer you are giving him an
instruction. The word xml tells him that you are using XML, the version
attribute tells what version of XML you are using and the encoding
attribute tells him how to encode the data (you would use a different
encoding if you wanted to use chinese text).

## \<!ELEMENT\> tag

The element tag is used to display an element of the page, depending on
how you declare it. It can go only on a specific part of the page or
anywhere on the page.

The first element you declare is the root element (in HTML it\'s html).
Let\'s pretend that there was an organization that wanted a bunch of XML
files containing info about each person. They probably would have a root
element of the file named \"person\". The standard for declaring an
element with children elements is

    <!ELEMENT elementName (childElement, childElement2, childElement3)>

So the orginization root element tag declaration would be

    <!ELEMENT person (firstName, lastName, postalCode, cellNumber, homeNumber, email)>

**Note**: A child element must be declared in a separate element tag to
be valid.

**Note**: The comma is used where you identify the child element is an
occurrence indicator (something that tells the computer how it should
occur). There are other occurrence indicators. We will cover them later
in this chapter.

**Note**: The parentheses define what content type is found in the
bracket. Different content types are found later in this chapter.

Some elements you don\'t want to be linked to specific tags (like a
formatting tag you want to use to highlight important info), you do the
same thing except you don\'t use it as a child element for any element
depending on your needs, you may use the ANY content type, which allows
you to use character data or other tags in your tag, the EMPTY content
type, which looks like \"`<exampleXmlTag />`{=html}\" or #PCDATA for
text.

**Note**:In an element declaration you can combine parentheses with
#PCDATA. It looks like this \<!ELEMENT elementName ( #PCDATA\|
childName). The pipe bar means that you can use text or other tags.

fr:Programmation XML/Définition de Type
Document


# XML - Managing Data Exchange/XHTML

------------------------------------------------------------------------

+---------------------------------------------------------+
| `<strong>`{=html}Learning objectives`</strong>`{=html}\ |
|                                                         |
| -   List the differences between XHTML and HTML         |
| -   Create a valid, well-formed XHTML document          |
| -   Convert an existing HTML document to XHTML          |
| -   Decide when XHTML is more appropriate than HTML     |
+---------------------------------------------------------+

In previous chapters, we have learned how to generate HTML documents
from XML documents and XSL stylesheets. In this chapter, we will learn
how to convert those HTML documents into valid XHTML. We will discuss
why XHTML has evolved as a standard and when it should be used.

## The Evolution of XHTML

Originally, Web pages were designed in HTML. Unfortunately most
implementations of this markup language allow all sorts of mistakes and
bad formatting. Major browsers were designed to be forgiving, and poor
code would display with few problems in most cases. This poor code was
often not portable between browsers, e.g. a page would render in
Netscape but not Internet Explorer or vice versa. The accounting for
human error and bad formatting takes an amount of processing power that
small handheld devices might not have. Thus when displaying data on
handhelds, a tiny mistake can crash the device.

XHTML partially mitigates these problems. The processing burden is
reduced by requiring XHTML documents to conform to the much stricter
rules defined in XML. Aside from the stricter rules, HTML 4.01 and XHTML
1.0 are functionally equivalent. If a document breaks XML\'s
well-formedness rules, an XHTML-compliant browser must not render the
page. If a document is well-formed but invalid, an XHTML-compliant
browser may render the page, so a significant number of mistakes still
slip through.

In this chapter, we will examine in detail how to create an XHTML
document.

The biggest problem with HTML from a design standpoint is that it was
never meant to be a graphical design language. The original version of
HTML was intended to structure human readable content (e.g. marking a
section of text as a paragraph), not to format it (e.g. this paragraph
should be displayed in 14pt Arial). HTML has evolved far past its
original purpose and is being stretched and manipulated to cover cases
that the original HTML designers never imagined.

The recommended solution is to use a separate language to describe the
presentation of a group of documents. Cascading Style Sheets (CSS) is a
language used for describing presentation. From version 1.1 of XHTML
upwards web pages must be formatted using CSS or a language with
equivalent capabilites such as XSLT (XSL Transformations). The use of
CSS or XSLT is optional in XHTML 1.0 unless the strict variant is used.
HTML 4.01 supports CSS but not XSLT.

## So What is XHTML?

As you might have guessed, XHTML stands for eXtensible HyperText Markup
Language. It is a cross between HTML and XML. It fulfills two major
purposes that were ignored by HTML:

1.  XHTML is a stricter standard than HTML. XHTML documents must be
    well-formed just like regular XML. This reduces vagaries and
    inconsistency between browsers, because browsers do not have to
    decide how to display a badly-formed page. Malformed XHTML is not
    allowed.\
    **Note 1:** Browsers only enforce well-formedness if the MIME
    type is set to `application/xhtml+xml`. If
    the MIME type is set to `text/html`, the browser will allow
    badly-formed documents. There are a large number of \'XHTML\'
    documents on the web that are badly-formed and get away with it
    because their MIME type is `text/html`.\
    **Note 2:** Browsers are not required to check for validity. See
    Invalid XHTML below for an example.
2.  XHTML allows for modularization (*m12n*). For different environments
    different element and attribute subsets can be defined.

The best thing about XHTML is that it is almost the same as HTML! If you
know how to write an HTML document, it will be very simple for you to
create an XHTML document without too much trouble. The biggest thing
that you must keep in mind is that unlike with HTML, where simple errors
like missing a closing tag are ignored by the browser, XHTML code must
be written according to an exact specification. We will see later that
adhering to these strict specifications actually allows XHTML to be more
flexible than HTML.

## XHTML Document Structure

At a minimum, an XHTML document must contain a DOCTYPE declaration and
four elements: html, head, title, and body:

``` XML
<!DOCTYPE ... >
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="...">
   <head>
      <title></title>
   </head>
   <body></body>
</html>
```

The opening `html` tag of an XHTML document must include a namespace
declaration for the XHTML namespace.

The DOCTYPE declaration should appear immediately before the html tag in
an XHTML document. It can follow one of three formats.

### XHTML 1.0 Strict

``` XML
<!DOCTYPE html
 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
```

The Strict declaration is the least forgiving. This is the preferred
DOCTYPE for new documents. Strict documents tend to be streamlined and
clean. All formatting will appear in Cascading Style
Sheets rather than the document itself. Elements
that should be included in the Cascading Style Sheet and not the
document itself include, but are not limited to:

    <nowiki>, nderline, old, talics, and </nowiki>

There are also certain instances where your code needs to be nested
within block elements. **Incorrect Example:**

    <nowiki>
I hope that you enjoy
 your stay.</nowiki>

**Correct Example:**

    <nowiki>
I hope that you enjoy your stay.
</nowiki>

### XHTML 1.0 Transitional

    <!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

This declaration is intended as a halfway house for migrating legacy
HTML documents to XHTML 1.0 Strict. The W3C encourages
authors to use the Strict DOCTYPE for new documents. (The XHTML 1.0
Transitional DTD
refers readers to the relevant note in the HTML4.01 Transitional
DTD.)

This DOCTYPE does not require CSS for formatting; although, it is
recommended. It generally tolerates inline elements found where
block-level elements are expected.

There are a couple of reasons why you might choose this DOCTYPE for new
documents.

-   You require backwards compatibility with browsers that support the
    formatting elements of XHTML but do not support CSS. This is a very
    small fraction of general users (less than 1%). Many browsers that
    don\'t support CSS don\'t support HTML 4.0 or XHTML either. However,
    it may be useful on a corporate intranet that has a larger than
    normal fraction of very old (pre-2000) browsers.
-   You need to link to frames. Using frames is discouraged as they work
    badly in many browsers.

### XHTML 1.0 Frameset

    <!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

If you are creating a page with frames, this declaration is appropriate.
However, since frames are generally discouraged when designing Web
pages, this declaration should be used rarely.

### XML Prolog

Additionally, XHTML authors are encouraged by the W3C to include the
following processing instruction as the first line of each document:

``` XML
<?xml version="1.0" encoding="UTF-8"?>
```

Although it is recommended by the standard, this processing instruction
may cause errors in older Web browsers including Internet Explorer
version 6. It is up to the individual author to decide whether to
include the prolog.

## Language

It is good practice to include the optional `xml:lang` attribute
1 on the html element to
describe the document\'s primary language. For compatibility with HTML
the `lang` attribute should also be specified with the same value. For
an English language document use:

``` XML
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
```

The `xml:lang` and `lang` attributes can also be specified on other
elements to indicate changes of language within the document, e.g. a
French quotation in an English document.

## Converting HTML to XHTML

In this section, we will discover how to transform an HTML document into
an XHTML document. We will examine each of the following rules:

-   Documents must be well-formed
    -   Tags must be properly nested
    -   Elements must be closed
-   Tags must be lowercase
-   Attribute names must be lowercase
-   Attribute values must be quoted
-   Attributes cannot be minimized
-   The name attribute is replaced with the id attribute (in XHTML 1.0
    both name and id should be used with the same value to maintain
    backwards-compatibility).
-   Plain ampersands are not allowed
-   Scripts and CSS must be escaped(enclose them within the tags
    \<!\[CDATA\[ and \]\]\>) or preferably moved into external files.

### Documents must be well-formed

Because XHTML conforms to all XML standards, an XHTML document must be
well-formed according to the W3C\'s recommendations for an XML document.
Several of the rules here reemphasize this point. We will consider both
incorrect and correct examples.

#### Tags must be properly nested

Browsers widely tolerate badly nested tags in HTML documents.

``` html4strict
<b><u>
This text is probably bold and underlined, but inside incorrectly nested tags.
</b></u>
```

The text above would display as bold and underlined, even though the end
tags are not in the proper order. An XHTML page will not display if the
tags are improperly nested, because it would not be considered a valid
XML document. The problem can be easily fixed.

``` html4strict
<b><u>
This text is bold and underlined and inside properly nested tags.
</u></b>
```

#### Elements must be closed

Again, XHTML documents must be considered valid XML documents. For this
reason, all tags must be closed. HTML specifications listed some tags as
having \"optional\" end tags, such as the `<p>` and `<li>` tags.

``` html4strict
<p>Here is a list:
<ul>
   <li>Item 1
   <li>Item 2
   <li>Item 3
</ul>
```

In XHTML, the end tags must be included.

``` XML
<p>Here is a list: </p>
<ul>
   <li>Item 1</li>
   <li>Item 2</li>
   <li>Item 3</li>
</ul>
```

What should we do about HTML tags that do not have a closing tag? Some
special tags do not require or imply a closing tag.

``` html4strict
<img src="titlebar.gif" alt="Title">
<hr>
<br>
<p>Welcome to my web page!</p>
```

In XHTML, the XML rule of including a closing slash within the tag must
be followed.

``` XML
<img src="titlebar.gif" alt="title" />
<hr />
<br />
<p>Welcome to my Web page!</p>
```

Note that some of today\'s browsers will incorrectly render a page if
the closing slash does not have a space before it (`<br/>`). Although it
is not part of the official recommendation, you should always include
the space (`<br />`) for compatibility purposes.

Here are the common empty tags in HTML:

-   area
-   base
-   basefont
-   br
-   hr
-   img
-   input
-   link
-   meta
-   param

### Tags must be lowercase

In HTML, tags could be written in either lowercase or uppercase. In
fact, some Web authors preferred to write tags in uppercase to make them
easier to read. XHTML requires that all tags be lowercase.

``` XML
<H1>This is an example of bad case.</h1>
```

This difference is necessary because XML differentiates between cases.
XML would read `<H1>` and `<h1>` as different tags, causing problems in
the above example.

``` XML
<h1>This is an example of good case.</h1>
```

The problem can be easily fixed by changing all tags to lowercase.

### Attribute names must be lowercase

Following the pattern of writing all tags in lowercase, all attribute
names must also be in lowercase.

``` XML
<p CLASS="specialText">Important Notice</p>
```

The correct tags are easy to create.

``` XML
<p class="specialText">Important Notice</p>
```

### Attribute values must be quoted

Some HTML values do not require quotation marks around them. They are
understood by browsers.

``` XML
<table border=1 width=100%>
</table>
```

XHTML requires all attributes to be quoted. Even numeric, percentage,
and hexadecimal values must appear in quotations for them to be
considered part of a proper XHTML document.

``` XML
<table border="1"  width="100%">
</table>
```

### Attributes cannot be minimized

HTML allowed some attributes to be written in shorthand, such as
selected or noresize.

``` html4strict
<form>
   <input checked ... />
   <input disabled ... />
</form>
```

When using XHTML, attribute minimization is forbidden. Instead, use the
syntax `x="x"`, where x is the attribute that was formerly minimized.

``` XML
<form>
   <input checked="checked"  .../>
   <input disabled="disabled"  .../>
</form>
```

A complete list of minimized attributes follows:

-   checked
-   compact
-   declare
-   defer
-   disabled
-   ismap
-   nohref
-   noresize
-   noshade
-   nowrap
-   readonly
-   selected
-   multiple

### The `name` attribute is replaced with the `id` attribute

HTML 4.01 standards define a name attribute for the tags
`a, applet, frame, iframe, img,` and `map`.

``` html4strict
<a name="anchor">
<img src="banner.gif" name="mybanner" />
</a>
```

XHTML has deprecated the name attribute. Instead, the id attribute is
used. However, to ensure backwards compatibility with today\'s browsers,
it is best to use both the name and id attributes.

``` XML
<a name="anchor" id="anchor" >
<img src="banner.gif" name="mybanner" id="mybanner"  />
</a>
```

As technology advances, it will eventually be unnecessary to use both
attributes and XHTML 1.1 removed name altogether.

### Ampersands are not supported

Ampersands are illegal in XHTML.

``` XML
<a href="home.aspx?status=done&itWorked=false">Home & Garden</a>
```

They must instead be replaced with the equivalent character code &.

``` XML
<a href="home.aspx?status=done&amp;itWorked=false">Home &amp; Garden</a>
```

### Image alt attributes are mandatory

Because XHTML is designed to be viewed on different types of devices,
some of which are not image-capable, alt attributes must be included for
all images.

``` XML
<img src="titlebar.gif">
```

Remember that the img tag must include a closing slash in XHTML!

``` XML
<img src="titlebar.gif" alt="title"  />
```

### Scripts and CSS must be escaped

Internal scripts and CSS often include characters like the ampersand and
less-than characters.

``` XML
<script language="JavaScript">
   <!--
      document.write('Hello World!');
   //-->
</script>
```

If you are using internal scripts or CSS, enclose them within the tags
and `]]>`. This will mark them as character data that should not be
parsed. If you do not use these tags, characters like & and \< will be
treated as start-of-character entities (like  ) and tags (like
\) respectively. This will cause your page to behave unpredictably,
and it may invalidate your code.

Additionally, the type attribute is mandatory for scripts. The comment
tags `<!--` and `-->` that have traditionally been used to hide
JavaScript from noncompliant browsers should not be included. The XML
standard states that text enclosed in comment tags may be completely
excluded from rendered documents, which would lose all script enclosed
in the tags.

``` XML
<script type="text/javascript" language="javascript">
/*<![CDATA[*/
   document.write('Hello World!');
/*]]>*/
</script>
```

Also `document.write();` is not permitted in XHTML documents. You must
used node creation methods such as `document.createElementNS();`
instead. Confusingly, `document.write();` will appear to work as
expected if the document is incorrectly served with a MIME type of
`text/html` (the type for HTML documents), instead of
`application/xhtml+xml` (the type for XHTML documents). If the MIME type
is `text/html` the document will be parsed as HTML which allows
`document.write();`. Parsing the document as HTML defeats the purpose of
writing it in XHTML.

Similar changes must be made for internal stylesheets.

``` XML
<style>
<!--
   .SpecialClass {
      color: #000000;
   }
-->
</style>
```

The type attribute must be included, and the CDATA tags should be used.

``` XML
<style type="text/css">
/*<![CDATA[*/
   .SpecialClass {
      color: #000000;
   }
/*]]>*/
</style>
```

Because scripts and CSS may complicate an XHTML document, it is strongly
recommended that they be placed in external .js and .css files,
respectively. They can then be linked to from your XHTML document.

``` XML
<script src="myscript.js" type="text/javascript" />

<link href="styles.css" type="text/css" rel="stylesheet" />
```

### Some elements may not be nested

The W3C recommendations state that certain elements may not be contained
within others in an XHTML document, even when no XML rules are violated
by the inclusion. Elements affected are listed below.

  Element   Cannot contain \...
  --------- -------------------------------------------------------------------------
  a         a
  pre       big, img, object, small, sub, sup
  button    button, fieldset, form, iframe, input, isindex, label, select, textarea
  label     label
  form      form

## When to convert

By now, it probably sounds as though converting an HTML document into
XHTML is easy, but tedious. When would you want to convert your existing
pages into XHTML? Before deciding to change your entire Web site,
consider these questions.

-   **Do you want your pages to be easily viewed over a nontraditional
    Internet-capable device, such as a PDA or Web-enabled telephone?
    Will this be a goal of your site in the future?** XHTML is the
    language of choice for Web-enabled portable devices. Now may be a
    good time for you to commit to creating an all-XHTML site.
-   **Do you plan to work with XML in the future?** If so, XHTML may be
    a logical place to begin. If you head up a team of designers who are
    accustomed to using HTML, XHTML is a small step away. It may be less
    intimidating for beginners to learn XHTML than it is to try teaching
    them all about XML from scratch.
-   **Is it important that your site be current with the most recent W3C
    standards?** Staying on top of current standards will make your site
    more stable and help you stay updated in the future, as you will
    only have to make small changes to upgrade your site to the newest
    versions of XHTML as they are approved by the W3C.
-   **Will you need to convert your documents to another format?** As a
    valid XML document, XHTML can utilize XSL to be converted into text,
    plain HTML, another XHTML document, or another XML document. HTML
    cannot be used for this purpose.

If you answered yes to any of the above questions, then you should
probably convert your Web site to XHTML.

### MIME Types

XHTML 1.0 documents should be served with a MIME
Type of `application/xhtml+xml`
to Web browsers that can accept this type. XHTML 1.0 may be served with
the MIME type `text/html` to clients that cannot accept
`application/xhtml+xml` provided that the XHTML complies with the
additional constraints in http://www.w3.org/TR/html/#guidelines
Appendix C
of the XHTML 1.0 specification. If you cannot configure your Web server
to serve documents as different MIME types, you probably should not
convert your Web site to XHTML.

You should check that your XHTML documents are served correctly to
browsers that support `application/xhtml+xml`, e.g. Mozilla Firefox. Use
\'Page Info\' to verify that the type is correct.

XHTML 1.1 documents are often not backwards compatible with HTML and
should not be served with a MIME type of
`text/html`.2

### Help Converting

-   Strict Alternatives to Deprecated Attributes for Elements in XHTML
    1.0 Strict

### HTML Tidy

When creating HTML, it\'s very easy to make a mistake by leaving out an
end tag or not properly nesting tags. HTML Tidy is a wonderful
application that can be used to correct a number of errors with poorly
formed HTML documents and convert it into XHTML. Tidy can also format
ugly code to be more readable, including code generated by WYSIWYG
editors. HTML Tidy can\'t generate clean code when it encounters
problems it isn\'t sure of how to fix. In these cases, it will generate
an error to let you know where the mistake is located in your document.

A few examples of problems that HTML Tidy can remedy:

-   Missing or mismatched end tags.
-   Improperly nested elements.
-   Mixed up tags.
-   Add a missing \"/\" to properly close tags.
-   Insert missing tags into lists.
-   Add missing quotes around attribute values.
-   Ability to insert the correct DOCTYPE value based on your code (can
    also recognize and report proprietary elements).

HTML Tidy can also be customized at runtime using a wide array of
command line arguments. It is capable of indenting code to make it more
readable as well as replacing FONT, NOBR, and CENTER tags with style
tags and rules using CSS. Tidy can also be taught new tags by declaring
them in the configuration file.

You can read more about HTML Tidy at the W3C\'s HTML
Tidy site, as well as download
the application as a binary or get the source code. There are several
sites that offer HTML Tidy as an online service including the
W3C and Site
Valet.

You can also validate your page using the validator available at
<http://validator.w3.org/>.

## When not to convert

You shouldn\'t convert your Web pages if they will always be served with
a MIME type of `text/html`. Make sure you know how to configure your
server or server-side script to perform HTTP content negotiation so that
XHTML capable browsers receive XHTML marked as `application/xhtml+xml`.
If you can\'t set up content negotiation, stick to HTML 4.01. People
viewing your Web pages with mainstream browsers will be unable to tell
the difference between a **valid** HTML 4.01 web page and a **valid**
XHTML 1.0 Web page.

Make sure the automated tests you run on your site simulate connections
from both XHTML-compatible browsers, e.g. Mozilla Firefox, and
non--XHTML-compatiable browsers, e.g. Internet Explorer 6.0. This is
particularly important if you use Javascript on your Web site. If
maintaining two copies of your test suite is too time consuming, don\'t
convert.

Bear in mind that valid HTML 4.01 Strict documents generally require
less effort to convert to XHTML 1.1 than valid XHTML 1.0 Transitional
documents. A valid HTML 4.01 Strict document can only contain elements
that are valid in XHTML 1.1, although a few attributes may need
changing. XHTML 1.0 Transitional documents on the other hand can contain
ten element types and more than a dozen attributes that are not valid in
XHTML 1.1. The XHTML 1.0 Transitional `body` element alone has six
atrributes that are not supported in XHTML 1.1.

Don\'t be pressured into using XHTML by people talking vaguely about
*bad practice*. Pin them down to what they mean by *bad practice*. If
they start talking about separation of content and presentation, they
have confused the differences between HTML and XHTML with the
differences between the Transitional and Strict doctypes. Both XHTML 1.0
Transitional and HTML 4.01 Transitional allow you to mix presentation
and content in the same document, i.e. they allow this type of bad
practice. Both HTML 4.01 Strict and XHTML 1.0 Strict force you to move
the bulk of the presentation (but not all of it) in to CSS or an
equivalent language. All four doctypes allow you to use embedded
stylesheets, whereas, true separation requires that all CSS and
Javascript be moved to external files.

## XHTML 1.1

XHTML 1.0 is a suitable markup language for most purposes. It provides
the option to separate content and presentation, which fits the needs of
most Web authors. XHTML 1.1 enforces the separation of content and
presentation. All deprecated elements and attributes have been removed.
It also removes two attributes that were retained in XHTML 1.0 purely
for backwards-compatibility. The `lang` attribute is replaced by
`xml:lang` and `name` is replaced by `id`. Finally it adds support for
ruby text found in East Asian documents.

### DOCTYPE

The DOCTYPE for XHTML 1.1 is:

``` XML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
```

### Modularization

The modularization of XHTML, or XHTML m12n, provides suggestions for
customizing XHTML, either by integrating subsets of XHTML into other XML
applications or extending the XHTML element set. The framework defines
two proceses:

-   How to group elements and attributes into \"modules\"
-   How to combine modules to create new markup languages

The resulting languages, which the W3C calls \"XHTML Host Languages\",
are based on the familiar XHTML structure but specialized for specific
purposes. XHTML 1.1 is an example of a host language. It was created by
grouping the different elements available to XHTML.

XHTML variations, while possible in theory, have not been widely
adopted. There is continuing work being done to develop host languages,
but their details are beyond the scope of this discussion.

## Invalid XHTML

XHTML-compliant browsers are allowed to render invalid XHTML documents
provided that the documents are well-formed. A simple example is given
below:

``` XML
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Invalid XHTML</title>
  </head>
  <body>
     <p>This sentence contains a <p>nested paragraph.</p></p>
  </body>
</html>
```

Save the example as `invalid.xhtml` (the .xhtml extension is important)
and open the page with Mozilla Firefox. The page will render even though
it is invalid.

## Summary

  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  XHTML stands for eXtensible HyperText Markup Language. XHTML is very similar to HTML, but it is stricter and easier to parse. XHTML documents must be well-formed just like regular XML. XHTML allows for modularization. XHTML code must be written according to an exact specification unlike with HTML, where simple errors like missing a closing tag are ignored by the browser. Adhering to these strict specifications actually allows XHTML to be more flexible than HTML. The benefits described in this summary are only gained if the MIME type of the document is `application/xhtml+xml`. XHTML documents can be validated but most browsers choose not to.
  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Exercises

## Answers

es:Lenguaje XHTML
is:XHTML