Cover Pages Logo SEARCH
Advanced Search
ABOUT
Site Map
CP RSS Channel
Contact Us
Sponsoring CP
About Our Sponsors

NEWS
Cover Stories
Articles & Papers
Press Releases

CORE STANDARDS
XML
SGML
Schemas
XSL/XSLT/XPath
XLink
XML Query
CSS
SVG

TECHNOLOGY REPORTS
XML Applications
General Apps
Government Apps
Academic Apps

EVENTS
LIBRARY
Introductions
FAQs
Bibliography
Technology and Society
Semantics
Tech Topics
Software
Related Standards
Historic

SGML/XML Kit - Default SGML/XML browser display


Date:      Wed, 17 Feb 1999 12:32:00 -0500
From:      Didier PH Martin <martind@netfolder.com>
To:        DSSSL mailing list <DSSSList@mulberrytech.com>
Subject:   Default SGML/XML browser display

HI,

With the help of David Pawson (who gave me the right hint) I debugged the dsssl script that displays the SGML/XML document.

The following script displays a SGML/XML document showing its structure with indentation. In the next SGML/XML kit, I'll include it to display a SGML or XML document by default if no style sheet is associated to the document. Until then, here is the script. If you have the latest SGML/XML kit just include the following PI in your SGML/XML document.

[Note: see the February 1999 announcement for the SGML/XML kit.]


SGML:
<?stylesheet href="default.dsl" type="text/dsssl" media="screen">

XML:
<?xml-stylesheet href="default.dsl" type="text/dsssl" media="screen"?>

Note: I gave it the name "default.dsl" to this script, you may change it to the name you want.

If you have any suggestion to improve it, don't hesitate, make a post.


dsssl Script:


<!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN">

(define *rgb-color-space*
  (color-space "ISO/IEC 10179:1996//Color-Space Family::Device RGB"))

 (define primary-blue-color
  (color *rgb-color-space* (/ 25 255) (/ 25 255) (/ 255 255)))

(define %single-indent% 20pt)

(define (copy-attributes nd indent)
  (let loop ((atts (named-node-list-names (attributes nd)))
             (resultstr ""))
    (if (null? atts)
        resultstr
        (loop
          (cdr atts)
          (let* ((name (car atts))
                 (value (attribute-string name nd)))
            (if value
              (string-append
                resultstr
                "&#RE;"
                indent
                name
                "=\""
                value
                "\"")
              resultstr))))))

(define (ancestors nl)
  (node-list-map
    (lambda (snl)
      (let loop
        ((cur (parent snl))
         (result (empty-node-list)))
        (if (node-list-empty? cur)
          result
          (loop (parent cur)
                (node-list cur result)))))
    nl))

(root
  (make scroll
    (process-children)))

(default
      (sosofo-append
      (make paragraph
        color: primary-blue-color
          start-indent: (* (node-list-length(ancestors(current-node)))
%single-indent%)
        (literal
          "<"
          (gi (current-node))
          (copy-attributes (current-node) (string-append "  "))
          ">"))
      (make paragraph
        lines: 'asis
        start-indent: (* (node-list-length(ancestors(current-node)))
%single-indent%)
        (process-children))
      (if (node-property 'must-omit-end-tag?   (current-node))
        (empty-sosofo)
        (make paragraph
          color: primary-blue-color
            start-indent: (* (node-list-length(ancestors(current-node)))
%single-indent%)
          (literal
            "</"
            (gi (current-node))
            ">")))))


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

Prepared by Robin Cover for the The SGML/XML Web Page archive.


Globe Image

Document URL: http://xml.coverpages.org/martinDefaultScript.html