chains of SXML transformations?
"Hoehle, Joerg-Cyril" <[email protected]> Tue, 21 Oct 2003 11:38:48 +0200
| Newsgroups | gmane.lisp.scheme.ssax-sxml |
|---|---|
| Message-ID | <[email protected]> |
Hi,
re-reading the SXML spec, it appears that my example
(define barf '(Coll (Header 123) ((Data ((Request))) (DSig 4))))
is not correct SXML. Superfluous nesting is not allowed.
Now I have a problem.
My original idea was to operate chains of transformations on a SXML source.
SXML --transform--> SXML --transform-->SXML ...
It's only the last transformation step that would produce XML.
I.e. pre-post-order handlers are in each step, whereas SRV:send-reply is only used at the final step.
The code works fine so far.
E.g.
SXML --transforms1-->"SXML"1
--transforms2-->"SXML"2
--XML-transforms-->XML
The intermediate data is not pure SXML as it now appears, because it contains too many nesting levels. These reflect the transformation handlers.
An example:
(define (transform1 sxml)
(pre-post-order sxml
(append
`((repeat *macro*
. ,(lambda (tag count . elems)
;;(require 'srfi-1) make-list from SRFI-1
(apply make-list count elems)))
other-transforms identity-transforms)))
(my-test '(Data (repeat 3 (random-Header 3))))
->
(Data
((Header VOTj)
(Header 0qel)
(Header bA97)))
See, the output is not strict SXML anymore.
Nevertheless, I can still feed that output into another pre-post-order stage.
But how to turn it into proper SXML again?
SXML seems required for SXPATH to work correctly.
In further transformation stages, I wanted to extract some information from the transformed (pseudo-)SXML.
SXPATH seemed appropriate, but doesn't work on pseudo-SXML.
Another approach looked cumbersome:
(pre-post-order (my-test '(Data (repeat 3 (rnd-Header 3))))
(append ;; extract header information only
`((Header *preorder* . ,(lambda (tag b64) b64))
(*text* . ,(lambda (trigger x) '()))
(*default* . ,(lambda (tag . elems) elems)))))
-> ((LtnJ GtBI yEhQ))
again, too deep nesting. I'd wish for (LtnJ GtBI yEhQ).
sxml:clean-feed is of no help in general, because it makes everything flat. It would be enough in this example, but I simplified and need to return nested structure.
Thanks for your help,
Jörg Höhle
-------------------------------------------------------
This SF.net email is sponsored by OSDN developer relations
Here's your chance to show off your extensive product knowledge
We want to know what you know. Tell us and you have a chance to win $100
http://www.zoomerang.com/survey.zgi?HRPT1X3RYQNC5V4MLNSV3E54