|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Keeping comments with relevant node when shorting
Hi Mike,
Keys are useful for this kind of grouping in XSLT 1.0. I've never retrieved comments with a key, but that doesn't make it impossible: <xsl:key name="comments-by-owner" match="comment()" use="generate-id(following-sibling::*[1])"/> This key will retrieve all the comments that precede a given element (sibling), except those that also precede an earlier element. Then when you have <!-- comment 1 --> <!-- comment 2 --> <!-- comment 3 --> <node/> <!-- comment 4 --> <!-- comment 5 --> <node/> <xsl:template match="node">
<xsl:copy>
<xsl:copy-of select="key('comments-by-owner',generate-id())"/
</xsl:copy>
</xsl:template>would move the comments that "belong" to each node, inside it: <node> <!-- comment 1 --> <!-- comment 2 --> <!-- comment 3 --> </node> <node> <!-- comment 4 --> <!-- comment 5 --> </node> This uses the key-based idiom for positional grouping you'll find documented at www.jenitennison.com (which we use typically to create hierarchies out of flat structures -- as I've done in the example above). XSLT 2.0 has nice grouping constructs you can use for this: look Ma, no keys. Cheers, Wendell At 03:32 PM 1/14/2005, you wrote: That sorts nicely but unfortunately, we have several comments in front of some node. ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








