Re: how to unwrap a tag in pre-post-order

Peter Bex <Peter.Bex-qWit8jRvyhVmR6Xm/[email protected]> Wed, 17 Aug 2011 14:34:25 +0200
Newsgroups gmane.lisp.scheme.ssax-sxml
Message-ID <[email protected]>
On Wed, Aug 17, 2011 at 01:47:57PM +0200, Oleg Parashchenko wrote:
> Hello,

Hi!

> I try to "unwrap" an XML tag: delete the tag, but retain the subtrees.
[snip]
> A first attempt with SXSLT:
> 
> (define doc '(*TOP* (chapter (proxy (section)) (proxy (section)))))
> (define unwrapped (pre-post-order doc `(
>   (*default* . ,(lambda args args))
>   (proxy     . ,(lambda (tag . kids) kids))
>   )))
> (display unwrapped)(newline)
> 
> The result is:
> 
> (*TOP* (chapter ((section)) ((section))))
> 
> But I want:
> 
> (*TOP* (chapter (section) (section)))
> 
> Any trick to get the desired result?

I think what you're looking for is "pre-post-order-splice":

(pre-post-order-splice doc
  `((*default* . ,(lambda args args))
    (proxy     . ,(lambda (tag . kids) kids)))))
=>
(*TOP* (chapter (section) (section)))

See the notes near the end of lib/SXML-tree-trans.scm in the SSAX
distribution.

HTH,
Peter Bex
-- 
http://sjamaan.ath.cx
--
"The process of preparing programs for a digital computer
 is especially attractive, not only because it can be economically
 and scientifically rewarding, but also because it can be an aesthetic
 experience much like composing poetry or music."
							-- Donald Knuth

------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system, 
user administration capabilities and model configuration. Take 
the hassle out of deploying and managing Subversion and the 
tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2