[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: [XSL] extracting a verse
David,
At 07:57 PM 12/18/2002, you wrote: I missed the start of this thread but is d-o-e acceptable? It is, if you allow that you're making the XSLT processor drive a fancy string-writing routine (here based on a tree walk), rather than doing a "proper" tree transformation. As you know better than anyone, David. :-> Whether the original poster (was it Michael?) can solve his problem by generating strings with a serializer, I can't say. (There are those, I hear, who believe a mere string can hardly amount to XML, and shouldn't be allowed to be processed by a computer at least unescorted). I note also the transformation has to know the element type of the outermost wrapper, here <quote>...</quote> (though I suppose this could be handled in other ways too). It *is* an ingenious approach (and requires a breakthrough, as I expected), and (I have no doubt) will be often resorted to (with its variations). It may even be a second reasonable use of d-o-e. The next thing wanted will be some alignment, so that successive <seg> elements, say, keep track of which other segs they belong to. I suppose you do this by faking an attribute that points to the parent, as in <xsl:template match="*"> <xsl:copy> <xsl:attribute name="id"> <xsl:value-of select="generate-id()"/> </xsl:attribute> <xsl:apply-templates/> </xsl:copy> </xsl:template> <xsl:template match="verse"> <xsl:text disable-output-escaping="yes"><verse></xsl:text> <xsl:for-each select="ancestor::*[ancestor::quote]"> <xsl:text disable-output-escaping="yes"><</xsl:text> <xsl:value-of select="name()"/> <xsl:text disable-output-escaping="yes"> align="</xsl:text> <xsl:value-of select="generate-id(..)"/> <xsl:text disable-output-escaping="yes">"></xsl:text> </xsl:for-each> </xsl:template> <xsl:template match="endVerse">... as you have it ...</xsl:template> Admiringly, Wendell If so it seems fairly easy, something like ... <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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
|