Re: sxml-match patterns
[email protected] Wed, 25 May 2005 12:30:26 -0700 (PDT)
| Newsgroups | gmane.lisp.scheme.ssax-sxml |
|---|---|
| Message-ID | <[email protected]> |
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