DTDHandler API

 


The simplest way to reference files containing binary data is to use MIME data types. If you are dealing with older SGML-style data, you'll need to an define an unparsed entity using the NDATA keyword:

<!ENTITY myEntity SYSTEM "..URL.." NDATA gif>

NDATA specifies a non-XML data type, in our case gif, which is not parseable. The DTD must include a declaration for the notation:

<!NOTATION gif SYSTEM "..URL..">

When the parser sees an unparsed entity or a notation declaration, it does nothing with the information except to pass it along to the application using the DTDHandler interface. That interface defines two methods:

notationDecl String(name, String publicId, String systemId) 

unparsedEntityDecl String(name, String publicId, 
  String systemId, String notationName) 

The notationDecl method is passed the name of the notation and either the public or system identifier, or both, depending on which is declared in the DTD. The unparsedEntityDecl method is passed the name of the entity, the appropriate identifiers, and the name of the notation it uses.

The DTDHandler interface is implemented by the DefaultHandler class.

Notations can also be used in attribute declarations. For example, the following declaration requires notations for the GIF and PNG image-file formats:

<!ENTITY image EMPTY>
<!ATTLIST image 
    ...
    type  NOTATION  (gif | png) "gif"
>

Here, the type is declared as being either gif, or png. The default, if neither is specified, is gif.

Whether the notation reference is used to describe an unparsed entity or an attribute, it is up to the application to do the appropriate processing. The parser knows nothing at all about the semantics of the notations. It only passes on the declarations.


 

Home