Pages: 1
Print
Author Topic: A ListBox for Selecting Preferred CDATA Attribute Values  (Read 4287 times)
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2618



WWW
« on: July 22, 2009, 10:46:06 AM »

Background
This example is being posted in response to another forum post asking for a way to configure XMetaL Author Enterprise to allow authors to select from a preferred list of values to populate the DITA outputclass attribute. That attribute is defined as CDATA, so XMetaL Author's Attribute Inspector simply shows a text edit box and allows you to enter values as free-form strings. That is the right thing to do because you are allowed to enter virtually anything in such an attribute and the product cannot predict what you might want to limit those values to, nor if there are any preferred values. However, for people that commonly use one or more values over and over this is not very convenient.

Purpose of this Example
This example is meant to be used to aid with authoring any document type that defines an attribute as allowing CDATA values for which you wish to provide a list of preferred values. It will not be useful for attributes that define an enumerated list of values because XMetaL Author will automatically display a listbox in the Attribute Inspector showing those values (and validate the document based on that list).

This example could be particularly useful for DITA documents because almost all (all?) attributes are defined as CDATA, but people often wish to use the same specific values over and over. I am pushing for a similar feature to be added to XMetaL Author Enterprise but do not know when that might happen.

Note that this sample could be used for any Schema or DTD, and in fact as it is currently written it will affect all document types. It is currently configured to allow the user to set values for the xml:lang attribute.

This sample does not add additional validation constraints nor does it restrict the user from entering values that are not preferred, it simply guides them by providing the list. If you have strict requirements for restricting an attribute's values to certain values it would be best to alter your schema, or in the case of DITA to create a specialization of one of the DTDs.

Requirements
This example uses a feature introduced with the 5.5 version of XMetaL Author Enterprise and XMetaL Author Essential. As written it will not work with older releases, though the same basic approach might be used.

Installation
1. Download the attached ZIP file and unzip it.
2. Place the XFT file inside the <xmetal install path>\Forms folder.
3. Place the MCR file inside the <xmetal install path>\Startup folder.

Running the Example
1. If XMetaL Author is running restart it.
2. Open a document that defines the xml:lang attribute (the example is configured to demo this attribute).
3. Place your selection inside an element that allows the xml:lang attribute.
4. Open the Attribute Inspector and select the xml:lang attribute.
5. Click the button labeled "..." to open the XFT and modify the preferred value.

Making Modifications
Instructions for modifying this sample to work with other attributes, disabling the xml:lang functionality, and for adding / removing attribute values are contained within the MCR file.

MCR files can be imported into existing XMetaL Developer customizations or you can edit them as plain text if you do not have XMetaL Developer. It should not be necessary to modify the XFT to get this working, but if you do need to modify it you will need a copy of the program xflayout.exe that ships with XMetaL Developer.

* CDATAattrValsViaListBox_Example.zip (3.09 KB - downloaded 380 times.)

* CDATAattrValsViaListBox_Example.jpg (67.02 KB, 840x559 - viewed 843 times.)
« Last Edit: July 22, 2009, 10:48:05 AM by Derek Read » Logged
Pages: 1
Print
Jump to:  

email us