[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: step-by-step work instructions -- recursive apply-
Kathy,
For a rather different approach to this, look at http://www.biglist.com/lists/xsl-list/archives/200304/msg00049.html It solves a deeper problem than you are faced with (though not much deeper :-), but simplified a bit it could be adapted to what you want to do. Explanation: consider source like this -- <div><label>1</label> <div><label>1.1</label> <div><label>1.1.1</label></div> </div> <div><label>1.2</label></div> <div> And templates like this: A. <xsl:template match="div"> <part> <xsl:apply-templates/> </part> </xsl:template> A1. <xsl:template match="div"> <part> <xsl:apply-templates select="label"/> </part> <xsl:apply-templates select="div"/> </xsl:template> B. <xsl:template match="label"> <head> <xsl:apply-templates/> </head> </xsl:template> Templates A and B together make <part> <head>1</head> <part> <head>1.1</head> <part> <head>1.1.1</head> </part> </part> <part> <head>1.2</head> </part> </part> Templates A1 and B together make <part> <head>1</head> </part> <part> <head>1.1</head> </part> <part> <head>1.1.1</head> </part> <part> <head>1.2</head> </part> which flattens the structure (what your tables look like). Of course, here the hierarchy is lost. If you want to represent it by some formatting, you can tweak template B like this: B1. <xsl:template match="label"> <head> <xsl:for-each select="ancestor::div"> <xsl:text>#</xsl:text> </xsl:for-each> <xsl:apply-templates/> </head> </xsl:template> Which combined with template A1 gives you <part> <head>1</head> </part> <part> <head>#1.1</head> </part> <part> <head>##1.1.1</head> </part> <part> <head>###1.2</head> </part> Which displays the hierarchy albeit not reflecting it directly. (Of course IRL the '#' will be spaces for indenting or whatever.) This is, in effect, the solution Americo is proposing (boiled down). At 11:52 AM 4/10/2003, you wrote: Also, just so you don't think I'm TRYING, I'm on my third XSLT book...but I can't find examples anywhere to match what I've been asking here. Things are hard to find not only because the topic is complex and explanations are ad hoc, but also because questions are naturally asked by people who do not (yet) know the terminology; hence it's hard to know what to search for. That's one reason we're here. :-> Good luck, Wendell
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
|