Frequently Asked Questions about Cost

Contents

Building Cost

Q1. On what platforms does Cost run?

A. So far (that I know of for sure):

It should work on any operating system to which Tcl 7.4 has been ported.

Some of the translation scripts require POSIX features like command pipelines, but other than that I believe Cost to be reasonably portable.

Q2. GCC complains. Is that OK?

A. gcc 1.3.7 gives spurious compiler warnings about "argument passing between incompatible pointer types". These can be ignored. I think it's because earlier versions of 'gcc' did not properly understand 'const' (either that or I don't properly understand 'const'!)

Q3. Help! [incr tcl] won't compile!

A. On some systems (notably SGI IRIX) you may need to add the line

	SHELL	= /bin/sh

to the Makefile after running './configure'.

A. There are some conflicts between [incr tcl] 1.5 and Tcl 7.4. However, the library 'libitcl.a' should build without any problems, and that's all that is needed to compile Cost. You can safely ignore the link errors and just use 'src/libitcl.a'.

If you want to go ahead and build itcl_sh and itcl_wish for other reasons, see the following from noted Tcl guru Jeffrey Hobbs:

Grab the t(cl|k)AppInit.c files from http://www.cs.uoregon.edu/jhobbs/, set the libraries in the Makefile to use the new tcl/tk ones, and recompile. No other itcl code has to change. You have to be careful when using globals in Tk4 with itcl1.5. You have to set them in the global scope (ie - use '::set' instead of just 'set'). You _may_ experience other problems.

A. You don't really need [incr tcl] to use Cost; I suggest waiting until 2.0 is released.

Q4. Is there an autoconfigure script for Cost?

A. No, and there probably won't be. Sorry.

Q5. What Tcl/Tk/ITCL versions are required?

A. Cost 2.0 requires Tcl 7.4, Tcl 7.5, or [incr Tcl] 2.0. It supports Tk 4.0, Tk 4.1, and (to some degree) [incr Tcl] 1.5, in various combinations.

The following combinations are known to work so far:

[0] This is the recommended configuration.

[1] Actually, this doesn't work very well.

[2] Note that CoST B4 is very different from Cost 2...

[3] ITCL 2 replaces Tcl 7.4 and Tk 4.0. It is not currently (October 1995) publically available.

Using Cost

Q6. Any examples of a simple translation script?

A. See the script that converts this FAQ list into HTML. (Included in the distribution.)

Q7. How do I specify a default rule for elements with the 'Simple' module?

A. The 'el' query clause matches any element node.

Note that in specifications, the order of rules is important: more specific rules like '{element LIST withattval FORMAT ALPHA}' should come before more general rules like '{el}'.

Q8. Where are # comments allowed?

A. #-style comments are only recognized in data that is interpreted as a Tcl script.

This means that you can't (easily) include comments inside a specification list. I'm looking into this problem...

Q9. How come there are so few questions in this section?

A. Nobody's asked very many :-(

Using SGMLS

Q10. How do I set SGML_PATH?

A. Good question. This is what I use:

setenv SGML_PATH "%S:%N.%Y:%N"

This seems to work most of the time. Your mileage may vary...

Using NSGMLS (part of SP) or SGMLS 1.1.91, PUBLIC identifiers and catalog files will greatly simplify things; See "What are catalogs and how do I use them? ".

Q11. SGMLS produces a gazillion error messages, but I'm sure the document is OK. What's up?

A. It could be a missing SGML declaration.

If you see error messages like the following:

Length of name, number, or token exceeded NAMELEN or LITLEN limit
Normalized length of literal exceeded 240; markup terminated
Content model token 33: more than GRPCNT model group tokens; terminated

then you probably just forgot to supply the SGML declaration. This can be passed to sgmls on the command line:

sgmls sgml-declaration.dcl mydoc.sgm | costsh -S myspec.spec

The Cost 'loaddoc' command will supply this parameter automatically if the $SGML_DECLARATION environment variable is set.

Q12. I don't have an SGML declaration. What do I do?

A. Ask whoever sent you the document or DTD to supply one.

A. If you're writing your own DTD, you can try using the SGML declaration that comes with Cost (see doc/sgmldecl in the distribution). It is based on the reference concrete syntax, with many of the quantity and capacity settings increased.

For more information about SGML declarations, see
URL:http://gopher.sil.org/sgml/topics.html#SGMLDecl
.

Q13. What are catalogs and how do I use them?

A. External entities (including DTDs and entity sets) are specified with a public identifier, a system identifier, or both.

The system identifier is a string that specifies how to find the entity. They are usually filenames, but they can also be URLs or formal system identifiers. As the term implies, system identifiers are system-specific. Public identifiers on the other hand are globally unique. For example, an SGML document might start with:

<!DOCTYPE DocBook 
    PUBLIC "-//Davenport//DTD DocBook//EN" 
    SYSTEM "/usr/local/lib/sgml/dtds/docbook.dtd"
>

Obviously the same SYSTEM identifier won't work on every machine, This is where catalogs come in: they map PUBLIC identifiers to SYSTEM identifiers, so that the exact location doesn't need to be specified in the document.

Catalog files look like this:

-- Davenport DTDs: --
PUBLIC "-//Davenport//DTD DocBook//EN" "dtds/docbook.dtd"
PUBLIC "-//Davenport//DTD DocBook V2.3//EN" "dtds/docbook.dtd"

-- Entity sets: --
PUBLIC "ISO 8879:1986//ENTITIES Added Latin 1//EN" "entities/iso-lat1.gml"
PUBLIC "ISO 8879:1986//ENTITIES Added Latin 2//EN" "entities/iso-lat2.gml"
PUBLIC "ISO 8879:1986//ENTITIES Greek Letters//EN" "entities/iso-grk1.gml"

SGMLS and NSGMLS look at the SGML_CATALOG_FILES environment variable for a list of catalogs to read. Here's what I use:

setenv SGML_CATALOG_FILES \
    "./catalog:$HOME/sgml/catalog:/usr/local/lib/sgml/catalog"

This tells the parser to look in the current directory, my personal directory ($HOME/sgml) and a system-wide directory when resolving public identifiers.

License and copyright issues

Q14. Can I use Cost in a commercial application?

A. Yes. From section 5 of the Artistic License under which Cost is provided:

[...] You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other [...] programs as part of a larger [...] software distribution provided that you do not advertise this Package as a product of your own.

Tcl, Tk, and SGMLS have similarly liberal licensing policies.

In particular, I consider an SGML processing application written on top of Cost to be a form of "support", so that's fine too.

Q15. Is Cost public domain?

A. No. It is, however, freely redistributable.

Miscellany

Q16. What does ``CoST'' stand for?

A. CoST was originally developed by Klaus Harbo when he was at the University of Copenhagen. In the tradition of ASP (Amsterdam SGML Parser), YASP (Yorktown SGML Parser), and YAO (Yuan-ze, Almaden, Oslo), it was named the Copenhagen SGML Tool.

Klaus has since moved on to bigger and better things, and Cost is no longer associated with Copenhagen. Cost 2 is sufficiently different from the original that I ought to give it a new name, but I just can't come up with a pronounceable acronym for ``San Francisco SGML Processor.''

So Cost really doesn't stand for anything anymore, except maybe ``Combination Of Sgmls and Tcl'' if you like.

Esoterica

Q17. Why doesn't 'query docroot child' work?

A. The root SD node may have PI node children preceding the document element node if, for example, the DTD contained processing instructions. Use 'query docroot child el' instead.

Q18. Why doesn't 'query? textnode in FOO' work?

A. Text nodes -- CDATA, SDATA, RE, and ENTREFs -- always appear as children of a PEL (pseudoelement) node, which in turn are children of EL (element) nodes. 'query? textnode in FOO' is a synonym for 'query? textnode parent withGI FOO'; what you really want is 'query? textnode within FOO', which is a synonym for '... ancestor withGI FOO'.

Note that 'query? textnode parent parent withGI FOO' would also work, but you don't usually want that -- this would select all text nodes that are directly contained in 'FOO' elements, but would fail for those that appear in subelements of a 'FOO'.


Joe English
Revision: $Revision: 1.2 $