[plt-scheme] Web programming .

From: YC (yinso.chen at gmail.com)
Date: Sun Dec 27 10:04:46 EST 2009

On Sat, Dec 26, 2009 at 9:43 PM, Nevo <sakur.deagod at gmail.com> wrote:

>  hi,
>   Sorry, forgive me not able to clarify more on this topic . Here's the
> piece of code from the Genshi template file :
>   <py:match path="body" once="true" buffer="false"><body>
>     ${select('*|text()')}
>     </body> </py:match>
>   The above code is just instructing the template engine to *select* the
> text content of node "body" from the XHTML streams.  That's the one I was
> asking actually.  There's a difference between Genshi and PLT scheme web
> template from my point of view , the former separates the template macros
> and the real content streams ,while the latter  combines the template macros
> (S-expressions) with the content. As suggested by Jay, I could use
> SXML/SXPATH library to parse the XHTML content and select those nodes which
> I'm interested in. Yeah, this is possible , but I havn't used that yet,  on
> a quick read of its tutorial (
> http://modis.ispras.ru/Lizorkin/sxml-tutorial.html) , I probably need to
> obtain a SXML representation of a document which means the template file
> should be expanded first (using @include-template) and then parse it using
> SXML parser into a SXML document before I can use SXPath on it, am I right ?
> Or is there a way to do it in template file itself ? Thanks.

You need to convert the xml string generated by include-template into sxml
in order to use sxpath, i.e.,

(require (planet lizorkin/sxml) (planet lizorkin/ssax/ssax)
((sxpath ...) (ssax:xml->sxml (open-input-string ((include-template
"template.html") ...))))

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20091227/1591374b/attachment.html>

Posted on the users mailing list.