International SGML/XML Users' Group
<home>
<about>
<technology>
  <introdution>
  <modelling>
  <syntax>
  <presentation>
  <linking>
  <graphics/>
  <multimedia>
  <knowledge>
  <database>
</technology>
<membership>
<chapters>
<contact>
<news>
<events>
<search>

Related Graphics Resources...
W3C SVG
SVG FAQ
Adobe SVG
WebCGM
CGM Open

Graphics in markup ...

The use of gaphics within markup has traditionally made use of links that have a picture file at the destination of the link. They have therefore been implemented in ways supported by the linking specifications, including using similar syntax to existing HTML images (the anchor tag). Images can also be referenced using SGML/XML's built-in NOTATION and ENTITY mechanism, as external unparsed entities.

Raw binary graphics files cannot be embedded directly into markup because any bytes that happen to resemble markup would get misinterpreted: so they must be refered to by linking. It is possible to include a text-encoded transformation of a binary file as a CDATA Marked Section, using something like UUencode with the markup characters ] and > removed from the map so that they could not occur and be misinterpreted, or even simple hexadecimal encoding as used in PostScript.

All the data in an XML document entity must be parseable XML. You can define an external entity as either a parsed entity (parseable XML) or an unparsed entity (anything else). Unparsed entities can be used for picture files, sound files, movie files, or whatever you like. They can only be referenced from within a document as the value of an attribute (much like a bitmap picture on an HTML Web page is the value of the img element's src attribute) and not part of the actual document. In an XML document, this attribute must be declared to be of type ENTITY, and the entity's declaration must specify a declared NOTATION, because if the entity isn't XML, the XML processor needs to know what it is. For example, in the following document, the colliepic entity is declared to have a JPEG notation, and it's used as the value of the empty dog element's picfile attribute.

    <?xml version="1.0"?> 
    <!DOCTYPE dog [
    <!NOTATION JPEG SYSTEM "Joint Photographic Experts Group">
    <!ENTITY colliepic SYSTEM "lassie.jpg" NDATA JPEG>
    <!ELEMENT dog EMPTY>
    <!ATTLIST dog picfile ENTITY #REQUIRED>
    ]>
    <dog picfile="colliepic"/>
The linking specifications, give much better control over the traversal and activation of links, so an author can specify whether or not to have an image appear when a page is loaded, or on a click from the user, or in a separate window, without having to resort to scripting.

SGML and XML do not restrict graphic file formats: GIF, JPG, TIFF, PNG, CGM, and SVG can all be used; however, vector formats are normally preferred for non-photographic images.

For XML, the XLink and XPointer linking specifications describe other ways to point to a non-XML file such as a graphic. These offer more sophisticated control over the external entity's position, handling, and appearance within the XML document.

For vector graphics, however, the solution is to use CGM or SVG. GIFs and JPEGs cater for bitmaps (pixel representations of images: all made up of coloured dots). Vector graphics (scalable, made up of drawing specifications) are being addressed in the W3C's graphics activity. It is possible to transmit the graphical representation as vectors directly within the XML file. For many graphics objects this will mean greatly decreased download time and scaling without loss of detail.

Copyright 2002 ISUG