Crane Softwrights Ltd.

Resource Library - Color - Examples

These are examples for using the DSSSL Color Declaration files described in the colorkey.htm file. The examples are documented as transcripts of a working Windows'95 DOS window session running JADE.

It is assumed the reader is already familiar with DSSSL syntax and is refering to these code fragments solely for the detail of accessing the color declarations.

Two examples are included, one illustrating direct access to the declarations, and the other illustrating indirect access to the declarations.

 Crane Logo

Sample SGML Open (OASIS) Format Catalog

The following file is used for an example, you can choose to use any public identifier you wish (or use system identifiers directly).

S:\colour>type color.soc
-- SGML Open Format Catalogue --

PUBLIC "+//ISBN 1-894049::CSL::Resources//DOCUMENT DSSSL Color Declarations//EN"
       "colordef.dsl"
PUBLIC "+//ISBN 1-894049::CSL::Resources//ENTITIES DSSSL Color Declarations//EN"
       "colordsl.ent"
PUBLIC "+//ISBN 1-894049::CSL::Resources//ENTITIES Color Declarations//EN"
       "colordef.ent"

-- end of file --

Direct access to the declarations

The following transcript illustrates the direct use of the entities available in each of two DSSSL scripts, the first for HTML and the second for RTF.

Note the HTML declarations are in a parameter entity, while the DSSSL declarations are in a general entity.

S:\colour>type testc.sgm
<!DOCTYPE doc [
<!ELEMENT doc - O (#PCDATA)>
]><doc>This is a test</doc>

S:\colour>type testch.dsl
<!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN"
[
<!-- declare, then include, the definitions of available entities -->
<!ENTITY % colorent
 PUBLIC "+//ISBN 1-894049::CSL::Resources//ENTITIES Color Declarations//EN">
%colorent;
]>

(declare-flow-object-class element
  "UNREGISTERED::James Clark//Flow Object Class::element")

(element doc
    (make element
        gi: "FONT"
        attributes: '(("COLOR" "&color-purple;"))
        (make element
            gi: "H1"
            (process-children))))

<!-- end of file -->


S:\colour>type testcr.dsl
<!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN"
[
<!-- declare the DSSSL code fragment declaring the color definitions -->
<!ENTITY colordef
 PUBLIC "+//ISBN 1-894049::CSL::Resources//DOCUMENT DSSSL Color Declarations//EN">
]>
&colordef;                              ;include the DSSSL code fragment

(element doc
    (make paragraph
        font-size:    20pt
        line-spacing: 20pt
        font-weight:  'bold
        color:        color-purple
        (process-children)))

<!-- end of file -->

S:\colour>jade -c p:\jade\jadecurr\catalog -c color.soc -t sgml -d testch.dsl   >testc.htm testc.sgm

S:\colour>jade -c p:\jade\jadecurr\catalog -c color.soc -t rtf  -d testcr.dsl -o testc.rtf testc.sgm

Indirect access to the declarations

In this example, note how a common entity file uses a general entity in the definition of a general entity named "&text-color;". The two DSSSL scripts are modified to reference the common general entity, which itself is defined using the general entity of the declaration. Since the DSSSL variables are referenced by their name, the DSSSL entity file is only a set of declarations of entities whose values are equivalent to their names.

In this way, the same general entity can be used in both kinds of scripts.

S:\colour>type testcmn.ent
<!-- testcmn.ent: a common declaration of a color to use in scripts
                  targetted for RTF and SGML -->

<!ENTITY  text-color  "&color-darkgreen;">

<!-- end of file -->

S:\colour>type testch2.dsl
<!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN"
[
<!-- declare, then include, the definitions of available entities -->
<!ENTITY % colorent
 PUBLIC "+//ISBN 1-894049::CSL::Resources//ENTITIES Color Declarations//EN">
%colorent;

<!-- declare, then include, the common definitions for both scripts -->
<!ENTITY % testcmn SYSTEM "testcmn.ent">
%testcmn;
]>

(declare-flow-object-class element
  "UNREGISTERED::James Clark//Flow Object Class::element")

(element doc
    (make element
        gi: "FONT"
        attributes: '(("COLOR" "&text-color;"))
        (make element
            gi: "H1"
            (process-children))))

<!-- end of file -->


S:\colour>type testcr2.dsl
<!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN"
[
<!-- declare the DSSSL code fragment declaring the color definitions -->
<!ENTITY colordef
 PUBLIC "+//ISBN 1-894049::CSL::Resources//DOCUMENT DSSSL Color Declarations//EN">

<!-- declare, then include, the definitions of available entities -->
<!ENTITY % colorent
 PUBLIC "+//ISBN 1-894049::CSL::Resources//ENTITIES DSSSL Color Declarations//EN">
%colorent;
<!-- declare, then include, the common definitions for both scripts -->
<!ENTITY % testcmn SYSTEM "testcmn.ent">
%testcmn;
]>
&colordef;

(element doc
    (make paragraph
        font-size:    20pt
        line-spacing: 20pt
        font-weight:  'bold
        color:        &text-color;
        (process-children)))

<!-- end of file -->

S:\colour>jade -c p:\jade\jadecurr\catalog -c color.soc -t sgml -d testch2.dsl   >testc2.htm testc.sgm

S:\colour>jade -c p:\jade\jadecurr\catalog -c color.soc -t rtf  -d testcr2.dsl -o testc2.rtf testc.sgm
98-06-15 15:30