Re: SXLST vs. XLST: Some practical questions
[email protected] Sat, 13 Dec 2003 00:02:48 -0800 (PST)
| Newsgroups | gmane.lisp.scheme.ssax-sxml |
|---|---|
| Message-ID | <[email protected]> |
Hello!
> I am particularly interested in the effect of "my-ss" in
> (pre-post-order doc my-ss) As far as I understand "my-ss" is a list of
> cons (<tag> . <function>). Thus the <function> is applied to a node
> of the sxml-tree whenever the tag-name matches <tag>. But what if I
> want some more context sensitive matching inside "my-ss".
There are many ways to arrange for a context-sensitive node
transformation. For example, if one wishes to apply a handler h to a
node 'elem' only if the node is a child of a node elem_p, he can
pre-post-order traverse the tree with the following stylesheet
(define my-ss
`(
...
(elem_p *preorder* .
,(lambda curr-node
(pre-post-order curr-node
(cons
`(elem . ,h)
my-ss))))
...))
That is, we add the rule (elem . ,h) only when we are traversing a
branch rooted at elem_p. If an element handler is defined with a tag
*preorder*, the handler receives the current node as it is. The
handler may examine the node in question and all of its children
before deciding which stylesheet to use to traverse that branch. A
document
http://pobox.com/~oleg/ftp/Scheme/sxslt-advanced.scm
(also in the SSAX repository, in the examples/ directory) illustrates
this approach in more detail. The document is meant as an executable
tutorial.
> <xsl:template match="elem1/[elem2/@key='value']">
> <xsl:copy-of select="//elem3[@id=current()/elem4]/*"/>
> </xsl:template>
If one wishes to process an SXML document in a XSLT manner, then the
STX approach pointed out by Kirill is the best bet.
Finally, if you have some particular transformation in mind, posting a
representative example could be helpful.
Cheers,
Oleg
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click