SGML for Windows NT: Setting up a free SGML/XML editing and publishing system on the Windows platform | ||
---|---|---|
Prev | Chapter 7. OpenJade and onsgmls | Next |
In this section we will have a brief look at the two tools openjade and onsgmls. At the moment we will use them by typing commands on the command line. This will give you some understanding about these tools, but keep in mind that you will be able to run these tools with a few mouseclicks from within Emacs at a later stage of this tutorial.
At first, we will check whether our test.sgml is a valid SGML file. As onsgmls is a command-line application, first open a NT command-line window. Change to the directory where your test.sgml was saved to and type the following command:
c:\user\myself> onsgmls -s test.sgml |
Note: The above command is the simplest possible case that happens to work for us because our DTD is very simple. In real life, you will have to provide a SGML declaration as the first non-option argument on the command line (the second argument is then the name of the file you want to process). Processing XML files requires additional command line switches besides a correct SGML declaration. Thus for a DocBook SGML document you would run:
c:\user\myself> onsgmls -s \path\to\docbook.dcl test.sgmlAnd for some XML document you'd have to type:
c:\user\myself> onsgmls -wxml -s \path\to\xml.dcl test.xmlThe -wxml switch gives you extended warnings for XML documents, while the -s switch suppresses the output of the parsed document contents.
This will parse the document and list any errors that it contains. Don't worry if onsgmls produces no output on the screen. This Unix-style brevity just means that there were no errors. To see an error message, change a tag in your test.sgml source file, e.g. change a h1 tag to read h and run onsgmls again.
Before we can try to process our test document with OpenJade, we need a stylesheet for our DTD. We will use a very simple stylesheet to create printable output from the test file that you created in the previous chapter. The stylesheet is borrowed from Paul Prescod, just like the DTD. Open a new file with the name test.dsl in the same directory as your test.sgml and type in or paste the following lines:
<!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN" > <style-sheet> <style-specification> <style-specification-body> (element HTMLlite (make simple-page-sequence)) (element H1 (make paragraph font-family-name: "Times New Roman" font-weight: 'bold font-size: 20pt line-spacing: 22pt space-before: 15pt space-after: 10pt start-indent: 6pt first-line-start-indent: -6pt quadding: 'center keep-with-next?: #t)) (element P (make paragraph font-family-name: "Times New Roman" font-size: 12pt line-spacing: 13.2pt space-before: 6pt start-indent: 6pt quadding: 'start)) (element EM (make sequence font-posture: 'italic)) (element STRONG (make sequence font-weight: 'bold)) </style-specification-body> </style-specification> </style-sheet> |
openjade is a command-line tool, just like onsgmls. Open a command-line window from your start menu. Change into the directory which contains your test SGML source and your stylesheet. There are some command-line options (see the file index.html in the OpenJade\jadedoc subdirectory), but all we need to know right now is the -t option to select the backend and the -d option to specify the stylesheet. We want to create a RTF file from our document, so the command is:
c:\user\myself> openjade -t rtf -d test.dsl test.sgml |
openjade should silently create the file test.rtf in the current directory. Try to open this document with any RTF-capable word processor (WordPad is sufficient for such a simple file).
Feel free to modify the stylesheet to better understand the effect of the style specifications. Change the font sizes or the fonts themselves, or change the line spacing. Use the additional Jade command line option -o output_file to provide a different output filename, e.g. test1.rtf, so you can easily compare the original output and the output created with your modified stylesheet.
With just a little more effort, we can also utilize the TeX backend and our TeX installation to create printable output:
C:\user\myself>openjade -t tex -d test.dsl test.sgml |
This will create the file test.tex. This is a LaTeX file which needs some special macros (the JadeTeX stuff) to be interpreted correctly by TeX. So the command line is:
C:\user\myself>jadetex test.tex |
This should create the standard set of .aux, .log, and .dvi files.
Create and view a PostScript document from your test.dvi. To this end, type the command:
C:\user\myself>dvips -o test.ps test.dvi |
and view the resulting file with:
C:\user\myself>gsview32 test.ps |
Alternatively, try to directly create a PDF document by typing:
C:\user\myself>pdfjadetex test.tex |
View the PDF file by typing:
C:\user\myself>gsview32 test.pdf |