SGML: Nifty Panorama Tricks

SGML: Nifty Panorama Tricks


Nifty Panorama Tricks
Subject: Nifty Panorama Tricks
Date: Sun, 31 Mar 1996 22:06:11 -0900
From: "W. Eliot Kimber" <kimber@passage.com>
Newsgroups: comp.text.sgml
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

It's a simple thing, but I found a really handy use for PanoramaPRO 1.5's "save as ASCII" feature, which saves whatever is on the screen, including generated text, so a text file. In order to do some cross-book HyTime linking, I needed to create nameloc elements for all the elements in the target document that had ID's. I realized I could use Panorama to generate the namelocs. Here's what I did: 1. Created a new style sheet for the target document. This style sheet has the following characteristics: A. Hides any element types that just contain PCDATA or will never have (or have subelements that have) IDs. B. For element types that can have IDs, creates a qualified style like so: Qualification: [ID] Text-Before: <nameloc id=\att(id)><nmlist docorsub=foo>\att(id)</nmlist></nameloc> The qualification "[ID]" is true anytime an ID attribute has a value. The Text-Before generates the nameloc you want, except that the DocorSub value will have to be changed (but presumably that's a single global change). You have to set this for each element type that might have an ID. If you have a lot, the easiest thing to do is do the first one, close Panorama, edit the SGML style sheet and copy the first one to do the rest. The style format is obvious and easy enough to work with. [I also like to set the base font to Courier for these styles to emphasize to myself that they're for generating text, not for browsing. I'm always doing a reload and then forgetting to change to my "transform" style again. The font change helps remind me to change the style.] 2. Apply the style and do "Save as ASCII". 3. Edit the resulting file to change "foo" to whatever it should be (i.e., name of the entity you've declared in the document you're addressing from to the document you're addressing to). 4. Include the namelocs into the document you're addressing from. This won't work for element types that could have IDs and occur in mixed content (unless you can figure out a clever way to generate comments around the PCDATA or something--haven't tried it). If your IDs are division elements, for example, it will work fine. This is way easier than writing a program to do the nameloc generation (at least for me). It's also representative of the type of simple transformation you can do quickly and easily using Panorama's style language. I find it's really useful for ad-hoc transformations where the cost of writing a program would generally outweigh the benefit, given that I'm not a SED/AWK/Perl whiz. Because of Panorama's easy style editor interface, it's easy to iterate over a transform until you get it right. Of course, there's a lot of things you can't do this way, but it's still a useful tool to have around and a non-obvious way to use this feature of Panorama. -- <Address HyTime=bibloc homepage="http://www.squirrel.com/squirrel/drmacro"> W. Eliot Kimber, kimber@passage.com Senior SGML Consultant and HyTime Specialist Passage Systems, Inc., 10596 N. Tantau Ave., Cupertino, CA 95014-3535 (408) 366-0300 (Cupertino), (512) 339-1400 (Austin), http://www.passage.com </Address> "If I never had existed, would you still remember me?..." --Austin Lounge Lizards, "1984 Blues" (http://www.webcom.com/~yeolde/all/lllhome.html)