Re: Simple guide to transformations using Jade (was titled similarly)

Subject: Re: Simple guide to transformations using Jade (was titled similarly)
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxx>
Date: Thu, 04 Jun 1998 13:09:49 -0400
At 14:48 98/06/03 +0100, Robin Stephenson wrote:
>I want to transform an SGML document from one DTD to another using
>Jade.  
>...
>What files do I need to create, where do I put them, and
>what command line do I use?

I've attached below a transcription of a working section from which you can
build what you need.  I'm assuming you've read enough about DSSSL to know
construction rules and flow objects, and just need to see an example of it
working.

>From the "jade.htm" information page, jump to the "transform.htm"
description of the semantics of James' SGML Transformation flow objects.

I hope this helps.

........... Ken


P:\JADE\misc>type this.sgm
<!DOCTYPE this SYSTEM "this.dtd">
<this>
<para>First paragraph
<ref addr="somewhere">
<para>Last paragraph
</this>

P:\JADE\misc>type this.dtd
<!ELEMENT this - O ( para | ref )*>
<!ELEMENT para - O ( #PCDATA )>
<!ELEMENT ref  - O EMPTY>
<!ATTLIST ref  addr CDATA #REQUIRED>

P:\JADE\misc>type that.dtd
<!ELEMENT that - O ( para | ref )*>
<!ELEMENT para - O ( #PCDATA )>
<!ELEMENT ref  - O EMPTY>
<!ATTLIST ref  addr CDATA #REQUIRED>

P:\JADE\misc>jade -c p:\jade\jadecurr\catalog -t sgml -d xform.dsl this.sgm
>that.sgm

P:\JADE\misc>type that.sgm
<!DOCTYPE that SYSTEM"that.dtd">
<that
><PARA
>First paragraph</PARA
><REF
ADDR="somewhere"><PARA
>Last paragraph</PARA
></that
>
P:\JADE\misc>nsgmls that.sgm
(THAT
(PARA
-First paragraph
)PARA
AADDR CDATA somewhere
(REF
)REF
(PARA
-Last paragraph
)PARA
)THAT
C

P:\JADE\misc>type xform.dsl
<!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN">

<!-- Crane Softwrights Ltd. - http://www.CraneSoftwrights.com
     (with excerpts from "transform.htm" in JADE deliverable)
-->

(define debug
  (external-procedure "UNREGISTERED::James Clark//Procedure::debug"))

(declare-flow-object-class element
  "UNREGISTERED::James Clark//Flow Object Class::element")
(declare-flow-object-class empty-element
  "UNREGISTERED::James Clark//Flow Object Class::empty-element")
(declare-flow-object-class document-type
  "UNREGISTERED::James Clark//Flow Object Class::document-type")
(declare-flow-object-class processing-instruction
  "UNREGISTERED::James Clark//Flow Object Class::processing-instruction")
(declare-flow-object-class entity
  "UNREGISTERED::James Clark//Flow Object Class::entity")
(declare-flow-object-class entity-ref
  "UNREGISTERED::James Clark//Flow Object Class::entity-ref")
(declare-flow-object-class formatting-instruction
  "UNREGISTERED::James Clark//Flow Object Class::formatting-instruction")
(declare-characteristic preserve-sdata?
  "UNREGISTERED::James Clark//Characteristic::preserve-sdata?"
  #t)

; *************
;
; Transformation Infrastructure:

; Make the output parseable
; - note this does not handle entity declarations; to do so, one would
;   walk the grove looking for entity references, and determining from
;   the properties, synthesize the entity declaration needed (but this
;   would end up with declarations for all entities encountered, not
;   just entities declared in the input internal declaration subset)
; - this code does not support processing instructions
; - this code relies on inline entity references to be to SDATA entities
;   to be preserved

(root
    (sosofo-append
        (make document-type             ;the prologue
            name:      "that"
            system-id: "that.dtd")
        (process-children)))            ;the content

; Handle all untouched elements

(define (copy-attributes #!optional (nd (current-node))) ;from transform.htm
  (let loop ((atts (named-node-list-names (attributes nd))))
    (if (null? atts)
        '()
        (let* ((name (car atts))
               (value (attribute-string name nd)))
          (if value
              (cons (list name value)
                    (loop (cdr atts)))
              (loop (cdr atts)))))))

(default
    (if (node-property "momitend" (current-node))        ;is EMPTY or #CONREF
        (make empty-element
              attributes: (copy-attributes))
        (make element
              attributes: (copy-attributes))))

; *************
;
; Handle all elements requiring change
;  - add here the construction rules effecting the transformation

(element this
    (make element
        gi: "that"
        (process-children)))

; end of file

P:\JADE\misc>



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


Current Thread
  • Idiots guide to transformations using Jade
    • Robin Stephenson - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id JAA07685Wed, 3 Jun 1998 09:56:06 -0400 (EDT)
      • G. Ken Holman - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id NAA09122Thu, 4 Jun 1998 13:14:22 -0400 (EDT) <=
        • Robin Stephenson - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id GAA07574Fri, 5 Jun 1998 06:54:57 -0400 (EDT)
          • Sebastian Rahtz - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id HAA08144Fri, 5 Jun 1998 07:30:31 -0400 (EDT)
          • Robin Stephenson - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id HAA08750Fri, 5 Jun 1998 07:56:17 -0400 (EDT)
          • Sebastian Rahtz - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id IAA09196Fri, 5 Jun 1998 08:16:52 -0400 (EDT)