RE: support for 'macro' formatting languages

Subject: RE: support for 'macro' formatting languages
From: Pieter Rijken <pieter.rijken@xxxxxx>
Date: Wed, 15 Dec 1999 11:52:57 +0100
> Pieter Rijken writes:
>  > However, since the SGML document actually is an 'article' and the
>  > publisher to which I will submit the article, uses LaTeX with the
>  > package 'revtex', not uncommon.
> 
> my advice: switch to another publish, if they cannot handle SGML/XML.

One does not always have a choice. Especially for very specialised
scientific
articles  one is stuck with a particular publisher. Not only because
there are only 1 or 2 journals to publish the article in, but also
because in that field of science it is 'common' to have the article
published by that publisher.

>  > In fact what happened is that I would like jade to generate
>  > the document in a 'macro language' like LaTeX with a 
> certain package.
> 
> in fact, the same process as HTML output. moral: write another
> stylesheet, like the HTML ones have to be

Well, because (Open)Jade already supports SGML -> SGML transformations
via a proprietary solution it is rather easy to get HTML output. The
backend to generate markup tags is already present.

Do you mean: write another backend?
Suppose I like the formatting of a 'chapter' in LaTeX, and I do not
want to figure out what spaces, indent, fonts, etc. LaTeX uses to
generate the desired layout. How do I generate the output of
"\chapter{title}"?

>  > What is the best solution? Does anyone have an idea? Any suggestion
>  > would help me alot.
> 
> I don't think there is a magic bullet. An SGML to LaTeX 
> transformation 
> is a high-level thing entirely at odds with the philosophy of DSSSL
> (and XSL FO). Of course, DSSSL (or XSLT) are good languages for
> writing this transformation

I totally agree with you that DSSSL isn't designed to do high level
transformations. But on the other hand, it would be nice to be
able to use DSSSL for this purpose.

One can always add yet another backend to get the desired output
format, but this does not seem an optimal solution and certainly
not maintainable and flexible.
If it boils down to choosing between 'two evils' (i'm not sure whether
this is an english expression...) and there is no alternative to
adding a new backend, then i'll just add the backend...

> 
> My personal solution is to have TeX parse the XML file.

I gave LaTeX just an example, probably it was a bad example.

At the moment I have two "serious" problems :-).

1) The first is
to generate UNIX manual pages. I could add a backend to generate
roff with the macros used by 'man'. But it would be nicer to have
generic roff support as well. Is there a way to have the same
backend support low level roff as well as one of the macro
packages?

2) At our company we use DECDocument (SDML, basically a macro package
on top of TeX) to write documents. I've written an SGML document
and want to generate HTML, RTF, and SDML... Because SDML has almost
no formatting constructs and consists only of macros like: chapter, section,
titlepage, table, etc. But one cannot specify the space between chapters,
table columns, or the line spcaing. So in this case I would like to
generate the macro statements for SDML.
At the moment i've written an SDML backend and i get reasonable documents
with it. But, in order to use the macros for sections, and chapters i
have a switch in the DSSSL style sheet. This is ugly, and not easy
to maintain if the style sheet changes.

Therefore i'm looking for another way to accomplish this before i go
on and start implementing a roff backend.

Unfortunately it is hard to have just one DSSSL style sheet for RTF
and SDML. This is because in the backend there is no flow object 
'chapter'.
(Because the SDML file is used to generate help-files for the
online documentation system 'BookReader' it is usefull to generate
SDML documents from SGML documents.)

I'll try to be more concrete. Suppose I have the following simple DTD:

<!-- doc.dtd -->
<!ELEMENT document - - (chapter+)>
<!ELEMENT chapter - - (#PCDATA)>
<!ATTLIST chapter title CDATA #REQUIRED>
<!-- end of doc.dtd -->

and i use the following DSSSL style sheet:

<!-- doc.dsl -->
(root (make simple-page-sequence (process-children)))
(element chapter
  (make sequence
    (make paragraph
      start-indent: 1cm
      font-size: 18pt
      font-weight: 'bold
      space-before: 2cm
      space-after: 2cm
      line-spacing: 18pt
      (literal (attribute-string "title")))
    (make paragraph
      (process-children-trim))))
<!-- end of doc.dsl -->

and the document instance on the above DTD:

<!-- doc.sgml -->
<!DOCTYPE document SYSTEM "doc.dtd">
<document>
  <chapter title="Chapter 1">
    blablabla
  </chapter>
</document>
<!-- end of doc.sgml -->

Clearly, the style sheet example above cannot generate macros
for a chapter, since the backend does not know that the
first paragraph flow object, represents a 'chapter'.

What one could do is define an architecture for the macro language:

<!-- macro.dtd -->
<!ELEMENT macrodocument - - (macrochapter+)>
<!ELEMENT macrochapter - - (#PCDATA)>
<!ATTLIST macrochapter title CDATA #REQUIRED>
<!-- end of macro.dtd -->

with the following style sheet (with special flow objects):
 
<!-- macro.dsl -->
(root (make simple-page-sequence (process-children)))
(element chapter
  (make macro-chapter
    title: (attribute-string "title")
    (process-children-trim)))
<!-- end of macro.dsl -->

Then make the following changes to the doc.dtd:

<!-- docnew.dtd -->
<!ENTITY % macroDtd SYSTEM "macro.dtd">
<!NOTATION MacroLanguage PUBLIC "<FPI for language 'macro'">
<!ATTLIST #notation MacroLanguage
  ArcDocF  NAME  #FIXED macrodocument
  ArcDTD   CDATA        "%macro"
  ArcFormA NAME  #FIXED macro
>

<?IS10744 ArcBase MacroLanguage>

<!ELEMENT document - - (chapter+)>
<!ATTLIST document macro NAME #FIXED "macrodocument">
<!ELEMENT chapter - - (#PCDATA)>
<!ATTLIST chapter title CDATA #REQUIRED
                  macro NAME #FIXED "maccrochapter">
<!-- end of docnew.dtd -->

After doing all this stuff it should be possible to generate
low-level output or at the macro-level:

jade -c catalog -d doc.dsl doc.sgml

or

jade -c catalog -A MacroLanguage -d macro.dsl doc.sgml

In this way one would have the DTD and DSSSL style sheet for
the macro language completely separated from the document
specific style sheet.

If one has, say, 10 types of SGML documents together with
10 stylesheets, one does not need to squeeze the macro
language into all 10 stylesheets. But declare that
all these document are derived from the same architectural form.

Would this be a clean way to support macro languages, e.g. UNIX
man pages?

pieter

-- 
Pieter Rijken                          E-mail: pieter.rijken@xxxxxx

CMG Telecommunications and Utilities B.V.
Division Advanced Technology
Nieuwekade 1-19
P.O. Box 8038                 Phone: +31 30 2339300
3503 RA Utrecht               Fax:   +31 30 2339495
The Netherlands
-------------------------------------------------------------------

DISCLAIMER: This statement is not an official statement from, nor
            does it represent an official position of, CMG
            Telecommunications and Utilities B.V.

------------------------------------------------------------------- 


 DSSSList info and archive:  http://www.mulberrytech.com/dsssl/dssslist


Current Thread