Re: Issues with literate programming DSSSL Script2

Subject: Re: Issues with literate programming DSSSL Script2
From: MARK.WROTH@xxxxxxxxxxx (Wroth, Mark)
Date: Mon, 20 Dec 1999 08:11:48 -0800
In response to my question, 

MBW> First: is there any way to couple some reasonable SGML and DSSSL to
MBW> a literal "<" in the output SGML entity?  Jade appears to want to

David Carlisle <davidc@xxxxxxxxx> suggested

DC>	  (make formatting-instruction
DC>		data:   "&#60;"

and I asked

MBW>The difficulty I have with this is that I don't see how to invoke it.
How do
MBW>I get DSSSL to apply this code when it encounters the relevant
MBW>character/entity? Or is the only answer to define an element <lt> which
MBW>then get a processing rule of its own?

and David replied

DC>Well the way I used this is just to use (make formatting-instruction
DC>for writing out _any_ strings in which you don't want < & and friends to
DC>be escaped. (The bit I posted was cut out of some code writing entity
DC>declarations for dtd fragments).

Hmmm.  I'm still not sure I understand what you're getting at. I did,
however, come up with a "solution" that uses the formatting-instruction.  I
define an element <literal> with one required attribute, which is the
literal data.  I then use an element rule like:

(element literal
  (make formatting-instruction
    data: (attribute-string "data")))

This allows me to insert <literal data="<"> in the document (or, more
pragmatically, define an entity which does so).  I still don't see a way to
do this without defining an element in the DTD, but this works acceptably.

I then asked

MBW>On a related note: what's wrong with this selector?
MBW>(with-mode continuation
MBW>  (process-node-list
MBW>     (select-elements (descendants (document-element (current-node)))
MBW>       '(scrap (continues attribute-string "id")))))

To which Brandon Ibach <bibach@xxxxxxxxxxxxxx> replied

BI>   Try this, instead:
BI>         `(scrap (continues ,(attribute-string "id")))
BI>   The problem here is that the single quote in your version quoted
BI>the *entire* expression, meaning that the "attribute-string" symbol
BI>and the "id" string got passed in as part of the pattern, rather than
BI>being evaluated and replaced with the value of the "ID" attribute.
BI>The backquote, above, introduces a "quasi-quote" expression, which is
BI>similar to a regular quoted expression, except that you can "unquote"
BI>certain parts of it, so that they will be evaluated.  In this case,
BI>we're unquoting the (attribute-string) call, such that the final
BI>result of this would be a structure like:
BI>         (scrap (continues "ABC"))
BI>if the current node was an element with an ID of ABC, that is. :)

This kind of makes sense (I *did* say that one of the purposes of this
exercise was to learn more about DSSSL, didn't I :-).  Once I realized that 

 '(scrap (continues ,(attribute-string "id")))

is not the same as 

 `(scrap (continues ,(attribute-string "id")))

This did indeed solve my problem.  With this in place, I think I have a
working "tangle".  Many thanks.

 DSSSList info and archive:

Current Thread