Re: [Webit-discuss] Re: sxml-match patterns
Alessandro Colomba <[email protected]> Wed, 25 May 2005 22:07:37 -0400
| Newsgroups | gmane.lisp.scheme.ssax-sxml |
|---|---|
| Message-ID | <[email protected]> |
Oleg, Thank you for your answer. I have been using sxslt until now, and moved towards sxml-match because of its (elegant!) macro-ish matching syntax and the fact that attribute matching is under-ordered. The latter is a feature I find particularly useful for my problem. (STX does not seem to possess it, from what I could see.) I had not considered combining sxslt and sxml-match together. I shall give it a try. Still, it would be interesting to find out the reason the stylesheet in my previous message generates the same tag twice. Also, I found two strange (to me) legal sxml-match stylesheets: ;; a) infinite loop at runtime (sxml-match sxml (,[x] x))) ;; b) runtime error "undefined variable x" (sxml-match sxml (,[x] (guard (string? x)) x))) I cannot quite figure out the rationale behind the grammar[*] specifying that a node can be a catamorphism. [*] http://celtic.benderweb.net/sxml-match/manual/index.html Thank you, ___ Alessandro On 5/25/05, [email protected] <[email protected]> wrote: > > > Hello! > > This is a reply to a message by Alessandro Colomba > on the webit-discuss mailing list: > http://sourceforge.net/mailarchive/forum.php?thread_id=7330228&forum_id=15740 > > The message might be of interest to other SXML users. > > Alessandro Colomba wrote: > > > Attempting to write a stylesheet to walk through an entire document, > > and match inner elements, I could not find a way to express something > > like: > > > > <!-- the identity transform --> > > <xsl:template match="@*|node()"> > > <xsl:copy> > > <xsl:apply-templates select="@*|node()"/> > > </xsl:copy> > > </xsl:template> > > Initially, wanting to copy a tree and transform only select elements,... > > It may be helpful to exploit the strengths of traversal and matching > (querying). Although you can use traversal for querying/matching (by > mapping non-matched or uninteresting elements to nothing) and > querying/matching for bulk transformations, that doesn't seem to be > the best use of either tool. The identity transform has the following > simple form in SXSLT: > > (pre-post-order sxml > `((*text* . ,(lambda (tag str) str)) > (*default* . ,(lambda node node)))) > > You can add more rules to transform some nodes differently. Please see > examples in SSAX/examples (in the CVS repository or in a SSAX > distribution). In particular, sxml-nesting-depth-label.scm > > It should be stressed that each SXSLT handler receives a node. So, a > handler can use sxml-match to match/transform just that particular > node. You can leave the rest of the traversing to pre-post-order > engine. > > If you're interested in translating XSLT stylesheets, you might want > to take a look at STX, > http://www196.pair.com/lisovsky/transform/stx/ > and http://www196.pair.com/lisovsky/query/ > > > Cheers, > Oleg > > > ------------------------------------------------------- > SF.Net email is sponsored by: GoToMeeting - the easiest way to collaborate > online with coworkers and clients while avoiding the high cost of travel and > communications. There is no equipment to buy and you can meet as often as > you want. Try it free.http://ads.osdn.com/?ad_id=7402&alloc_id=16135&op=click > _______________________________________________ > Webit-discuss mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/webit-discuss > On 5/25/05, [email protected] <[email protected]> wrote: > > > Hello! > > This is a reply to a message by Alessandro Colomba > on the webit-discuss mailing list: > http://sourceforge.net/mailarchive/forum.php?thread_id=7330228&forum_id=15740 > > The message might be of interest to other SXML users. > > Alessandro Colomba wrote: > > > Attempting to write a stylesheet to walk through an entire document, > > and match inner elements, I could not find a way to express something > > like: > > > > <!-- the identity transform --> > > <xsl:template match="@*|node()"> > > <xsl:copy> > > <xsl:apply-templates select="@*|node()"/> > > </xsl:copy> > > </xsl:template> > > Initially, wanting to copy a tree and transform only select elements,... > > It may be helpful to exploit the strengths of traversal and matching > (querying). Although you can use traversal for querying/matching (by > mapping non-matched or uninteresting elements to nothing) and > querying/matching for bulk transformations, that doesn't seem to be > the best use of either tool. The identity transform has the following > simple form in SXSLT: > > (pre-post-order sxml > `((*text* . ,(lambda (tag str) str)) > (*default* . ,(lambda node node)))) > > You can add more rules to transform some nodes differently. Please see > examples in SSAX/examples (in the CVS repository or in a SSAX > distribution). In particular, sxml-nesting-depth-label.scm > > It should be stressed that each SXSLT handler receives a node. So, a > handler can use sxml-match to match/transform just that particular > node. You can leave the rest of the traversing to pre-post-order > engine. > > If you're interested in translating XSLT stylesheets, you might want > to take a look at STX, > http://www196.pair.com/lisovsky/transform/stx/ > and http://www196.pair.com/lisovsky/query/ > > > Cheers, > Oleg > > > ------------------------------------------------------- > SF.Net email is sponsored by: GoToMeeting - the easiest way to collaborate > online with coworkers and clients while avoiding the high cost of travel and > communications. There is no equipment to buy and you can meet as often as > you want. Try it free.http://ads.osdn.com/?ad_id=7402&alloc_id=16135&op=click > _______________________________________________ > Webit-discuss mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/webit-discuss > ------------------------------------------------------- SF.Net email is sponsored by: GoToMeeting - the easiest way to collaborate online with coworkers and clients while avoiding the high cost of travel and communications. There is no equipment to buy and you can meet as often as you want. Try it free.http://ads.osdn.com/?ad_idt02&alloc_id135&op=click