DTD NOTATION

DTD > Structure > DTD NOTATION

The NOTATION Declaration can be used within an DTD to qualify the data contained within an external entity (non-xml) file.

The following EBNF describes the form the declaration takes. 

[82]   NotationDecl        ::=       '<!NOTATION' S Name S (ExternalID | PublicID) S? '>'

[83] PublicID ::= 'PUBLIC' S PubidLiteral

[75] ExternalID ::= 'SYSTEM' S SystemLiteral | 'PUBLIC' S PubidLiteral S SystemLiteral

A Notations provide information about the format of external entities (non-XML) files such as an image or video file that are effectively included into a source XML file. This allows the XML Parser or client application to correctly process the data contained.

The notation syntax takes the following forms

<!NOTATION Name PUBLIC PublicID>

A notation called Name is defined that describes data that is of a type defined by the PublicID. The PublicID refers to the name of a format considered to be standard (although the client application may not be aware of it).

<!NOTATION jpg PUBLIC "JPG 1.0">
<!NOTATION gif PUBLIC "GIF 1.0">
<!NOTATION png PUBLIC "PNG 1.0">

<!NOTATION Name PUBLIC PublicID SystemID>

A notation called Name is defined. This describes data of a type defined by the PublicID and/or SystemID. It is up to the client application to determine the way in which to treat the data by looking at either (or both) the PublicID or SystemID.

The PublicID refers to the name of a format considered to be standard.

The SystemID refers to the an identifier that the client application can use to lookup a resource that will be able to interpret the data, this is typically proprietary to the XML/DTD/Client application, in this case we have used mime types (but equally it could be the path to an application that can deal with the data, or just an ID the client application can understand).

<!NOTATION jpg PUBLIC "JPG 1.0" "image/jpeg">
<!NOTATION gif PUBLIC "GIF 1.0" "image/gif">
<!NOTATION png PUBLIC "PNG 1.0" "image/png">

Its now up the client application, it could look at the PublicID "JPG 1.0" and have inbuilt processing for JPEG's, if not is may choice to look at the SystemID "image/jpeg" and lookup a processesor from a list of mime types is knows about.

<!NOTATION Name SYSTEM SystemLiternal>

A notation called Name is defined. This describes data of a type defined by the SystemID.

The SystemID refers to the an identifier that the client application can use to lookup a resource that will be able to interpret the data, this is typically proprietary to the XML/DTD/Client application, in this case we have used mime types.

<!NOTATION gif SYSTEM "image/gif">
<!NOTATION jpg SYSTEM "image/jpeg">
<!NOTATION png SYSTEM "image/png">

Name must be unique within the loaded DTDs


Using Notations

Once a notation is defined within a DTD we can associate a ENTITY with it

<!ENTITY companyLogo
         SYSTEM "http://www.liquid-technologies.com/Images/Logos/Liquid/Liquid_Logo.gif"
         NDATA gif>

This defines an external entity called companyLogo which contains the data held within the url http://www.liquid-technologies.com/Images/Logos/Liquid/Liquid_Logo.gif.

The value of the NDATA (Notation Data) parameter tells the XML Parser which notation to associate with the data, this in tern tells the client application how to deal with the data.

In order to use the new entity we must define an attribute of type entity.

<!ELEMENT img EMPTY>
<!ATTLIST img src ENTITY #REQUIRED>

Finally we can use this within an XML document

 <img src="/Content/Glossary/companyLogo"/>

When the XML Parser sees the src attribute it know its an entity, so it resolves "companyLogo" back to the external entity described by the uri "http://www.liquid-technologies.com/Images/Logos/Liquid/Liquid_Logo.gif", it also knows that the data described by this external entity is of type "gif", which it resolves back to the notation letting it know that this data is defined by either the PublicID "GIF 1.0" or the SystemID "image/gif".

 

See Also

Try Liquid XML Free and see how we can help you today Free Trial