The unparsed entities are data which cannot be parsed by the XML parser and are sent to application for handling. Examples of unparsed entites are jpegand, gif files, QuickTime movie , MIDI sound files, special characters such as <, & …etc... These unhandled data are sent as an external unparsed entity to the application handling XML file.

Notations

Notations are declarations of unparsed entities. They tell the application handling the XML data, the unparsed data format and its path. The notations are declared in DTD and always have a name and external identifier.

Syntax for notations

<!NOTATION format_of_data SYSTEM identifier>

<!NOTATION format_of_data PUBLIC identifier>

Where,

  • NOTATION is the keyword,
  • format_of_data – This is the format of the unparsed data.
  • Identifier – This is the string which explains the type of data. There is no standard defining this string. It is dependent on the application to provide options for this value. It can be a MIME type, ISO standard, or an URL to a specification of the format.

Example of XML notations

<!NOTATION jpeg SYSTEM “image/jpeg”>

Data

Though all character data are parsed by XML, there are characters like “<”, “&” which are interpreted as tags or start of character entity. To avoid parsing errors of these data, CDATA sections are used in XML. CDATA stands for unparsed Character data. The data within this notation is ignored by parser. However CDATA cannot have ‘]]>’ as data as it marks end of CDATA section. It cannot contain spaces or line breaks. Nested CDATA are not allowed.

Example of XML data

<script>

<![CDATA[

      for(i=0;(i<10)&&(i>5); i++){

            document.write(i);

}

]]>

</script>

Parameter entities

XML document refers to the unparsed data through unparsed external entity. For parsed data, entity reference replaces the parsed text. However with unparsed data, entity reference cannot replace the text. Unparsed entities are used as attribute values on elements. The ENTITY/ENTITIES type of attribute is used to associate an entity with the unparsed data. The entities should be declared in DTD. 

Example of XML parameter unparsed entities

<!NOTATION JPEG SYSTEM “image/jpeg”>

<!ATTLIST logo image ENTITY #REQUIRED>

<!ENTITY myPicture SYSTEM “pic.jpg” NDATA JPEG >

Where,

  • ATTLIST: declares the attribute.
  • logo: element having attribute
  • image: name of the attribute.
  • ENTITY: If there are more than one unparsed element to be added to an attribute, ENTITIES type is used.
  • myPicture - the name of the entity.
  • “pic.jpg” - the name of the URL which can be absolute or relative.
  • NDATA - stands for Non Parsable Data (Notations)
  • JPEG - derived from notation name.           

Here, in the example above, it is upto the application to display the unparsed image.

Complex example of XML parameter unparsed entities

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

<!DOCTYPE root[

    <!ELEMENT root (logo)>

    <!ELEMENT logo EMPTY>

    <!ATTLIST logo image ENTITY #REQUIRED>

    <!NOTATION GIF SYSTEM "Photo in gif format" >

    <!ENTITY myPic SYSTEM "IMG_0689.gif" NDATA GIF>

]>

<root>

   <logo image="myPic"/>

    <![CDATA[

    <script>

        for(i=0;(i<10)&&(i>5); i++){

            document.write(i);

        }

 

    </script>

 

    ]]>

</root>

Output of the example above is:

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

  <!DOCTYPE root (View Source for full doctype...)>

 <root>

  <logo image="myPic" />

 <![CDATA[

    <script>

        for(i=0;(i<10)&&(i>5); i++){

            document.write(i);

        }

    </script>

  ]]>

  </root>

 

›› go to examples ››