Subject: Re: [xsl] Converting milestone tags From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Thu, 14 Oct 2010 10:35:22 -0400 |
Cheers, Wendell
This class of problems is quite tricky. The most general approach is to flatten the first hierarchy, so everything is reduced to milestones, and then use positional grouping to construct the new hierarchy from the flat structure.
If you have access to a good library, try looking for Michael Jackson's 1970s books on Jackson Structured Programming, where he tackles this class of problem under the heading of "boundary conflict". The vocabulary is different - it's all about sequential processing of hierarchic files on magnetic tape - but the logic is the same, and it's the most systematic treatment I've seen. Essentially he shows that if the hierarchic structure of the input and output are in some sense congruent, then a single tree walk over the input can handle the problem, but if they aren't then you can devise a new intermediate hierarchy - perhaps very flat - that is congruent with both the input and the output, so one tree walk will get you from the input to the intermediate tree, and a second tree walk will get you from the intermediate tree to the output. (This is assuming of course that you don't have an ordering conflict, which is true in your case).
Your example doesn't need the full generality of this approach, because the start/end milestones are always siblings and are always matched in the same paragraph, but your discussion indicates that you might want to tackle things that go beyond this example.
Michael Kay Saxonica
====================================================================== 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 ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Converting milestone tags, Praveen Chauhan | Thread | Re: [xsl] Converting milestone tags, Josef Schneeberger |
Re: [xsl] Client-side XSLT and Java, Eric J. Bowman | Date | Re: [xsl] Searching for values in X, Jacobus Reyneke |
Month |