81. viewObject
Prev | Chapter 6. Commands written in the Java™ programming language | Next

## 81. viewObject

Parameter syntax:

    [ '[implicitElement]' ]?
        S [ attribute_name|'-'
            S ['anyURI'|'hexBinary'|'base64Binary'|'XML']? ]?

Opens in associated helper application, the ``object'' contained or represented by implicitly or explicitly selected element.

This command may be used for example to open an image in an external image viewer, to open a PDF file in Adobe Acrobat Reader, etc.

Helper applications are declared using the Preferences dialog box, Helper Applications section.

The parameter may be used to specify where to find the object of interest and also the data type of this object:

attribute_name

  This parameter specifies the name of the attribute containing the URL of the object or directly containing the object data encoded in '`hexBinary`' or in '`base64Binary`'.

  If this parameter is absent (or is '`-`'), it is the selected element itself which contains the URL of the object or which directly contains the object data in '`hexBinary`', '`base64Binary`' or XML formats.

anyURI, hexBinary, base64Binary, XML

  Specifies how the object is ``stored'' in the element or in the attribute. Data type '`XML`' is only allowed for elements (typically a `svg:svg` or a `mml:math` element).

  If this parameter is absent, the data type is found using the grammar of the document. Of course, this cannot be guessed for documents conforming to a DTD (too weakly typed) and also for invalid documents conforming to a W3C XML or RELAX NG schema.

When the parameter is absent, which is often the case, this command will try to guess what object is to be opened using both the grammar of the document and how helper applications have been declared in the Preferences dialog box, Helper Applications section.

Once again this will work fine for documents conforming to a W3C XML or RELAX NG schema and not that great for documents conforming to a DTD.

The heuristic used for that is:

1. If a helper application is associated to the namespace of selected element (e.g. `svg:svg` or a `mml:math`), extract the element from the document and open it in helper application.

2. If selected element contains binary data (i.e. encoded in base 16 or base 64) and a helper application is associated to the signature (also called ``magic string'') of this data, extract the data from the element, decode it and open it in helper application.

3. if selected element contains an URI and a helper application is associated to the filename extension of this URI, open the URI in helper application.

4. Now examine the attributes of the selected element. In a first pass, only examine required attributes. In a second pass, examine the remaining attributes.

   1. If the attribute contains binary data and a helper application is associated to the signature of this data, extract the data from the attribute, decode it and open it in helper application.

   2. If the attribute contains an URI and a helper application is associated to the filename extension of this URI, open the URI in helper application.

      This step also applies if the data type of the attribute is `string` and not `anyURI`, as this is always the case with documents conforming to a DTD.

Note that this command considers that the default viewer (specified in the Preferences dialog box, Helper Applications section, Default viewer field; typically a Web browser) should be able to open html, text, GIF, JPEG and PNG files[5]. Therefore, in last resort, it may endup invoking the default viewer.

Examples:

    viewObject
    viewObject [implicitElement]
    viewObject fileref anyURI
    viewObject - XML
    viewObject [implicitElement] {http://www.w3.org/1999/xlink}href

See also editObject.

[5] Command `viewObject` also considers that the default viewer should be able to open URLs starting with "`http://`" and "`https://`". DocBook example: this is handy for displaying `<ulink url="http://www.xmlmind.com/xmleditor/"/>`.

Prev | Up | Next
80. undo | Home | 82. wrap