Complexity???

Subject: Complexity???
From: "Didier PH Martin" <martind@xxxxxxxxxxxxx>
Date: Sat, 8 May 1999 12:49:01 -0400
Hi,

I just cached on the XSL list a generic script to display any XML document
like I did with DSSSL. There is minor differences between the two scripts
but you can judge by yourself the complexity comparison between XSL and
DSSSL. I hope that seeing the two beast in the same cage will reduce the
smoke, bell and whistle and the hype that often surrounds technologies.

PS: I'll modify the XSL script so that both scripts do exactly the same
thing (and post that in an article). I used the classic lisp based notation
for those with allergic reactions :-)))

regards
Didier PH Martin
mailto:martind@xxxxxxxxxxxxx
http://www.netfolder.com

a) XSL scrip
------------

<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl";>

<xsl:script>


</xsl:script>

  <xsl:template><xsl:apply-templates/></xsl:template>

    <xsl:template match="*">
      <DIV STYLE="margin-left:1em; color:red">
        &lt;<xsl:apply-templates for="@*"/>/&gt;
      </DIV>
    </xsl:template>

    <xsl:template match="*[node()]">
      <DIV STYLE="margin-left:1em">
        <SPAN STYLE="color:blue">&lt;
            <xsl:apply-templates select="@*"/>
            <xsl:attribute/>
            &gt;
        </SPAN>
            <xsl:apply-templates select="node()"/>
        <SPAN STYLE="color:green">&lt;/<xsl:attribute />
        /&gt;</SPAN>
      </DIV>
    </xsl:template>

    <xsl:template match="@*">
      <SPAN STYLE="color:navy"> ="<SPAN STYLE="color:black"></SPAN>"</SPAN>
    </xsl:template>

    <xsl:template match="pi()">
      <DIV STYLE="margin-left:1em; color:maroon">&lt;
        <xsl:attribute/>
        <xsl:apply-templates select="@*"/>
        <xsl:value-of/>
        &gt;</DIV>
    </xsl:template>

    <xsl:template
match="cdata()"><pre>&lt;![CDATA[]]&gt;</pre></xsl:template>

    <xsl:template match="textnode()">
        <xsl:value-of/>
    </xsl:template>


<xsl:template match="/">
  <HTML><TITLE>XML via XSL sample</TITLE>
  <BODY>
   <H1 STYLE="Font-family: Arial; color: blue">
    <img src="xmledi.gif" align="middle"/>
    XML via XSL sample
   </H1>
    <xsl:apply-templates/>
  </BODY></HTML>
</xsl:template>


</xsl:stylesheet>


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 (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))))))

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

(default
  (make display-group
    start-indent: (+ (inherited-start-indent) 20pt)
    (make paragraph
      color:                          primary-blue-color
      font-weight:                    'light
   font-family-name: "Verdana"
   font-size:        10pt
      (literal
       "<"
       (gi (current-node))
       (copy-attributes (current-node) (string-append "  "))
       ">"))
    (if (node-property 'must-omit-end-tag?   (current-node))
       (empty-sosofo)
       (sosofo-append
	 (make paragraph
	    lines: 'asis
          font-weight:      'bold
          font-family-name: "Verdana"
          font-size:        10pt
	    (process-children))
	 (make paragraph
          color:  	    primary-blue-color
          font-weight:      'light
          font-family-name: "Verdana"
          font-size:        10pt
	    (literal "</" (gi (current-node)) ">"))))))


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


Current Thread
  • Complexity???
    • Didier PH Martin - Sat, 8 May 1999 14:04:40 -0400 (EDT) <=