Subject: Re: [xsl] Nesting a flat XML structure From: "Imsieke, Gerrit, le-tex gerrit.imsieke@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Mon, 29 Oct 2018 22:12:48 -0000 |
Agreed Wendell and Graydon. I am already doing multiple passes to get the content in a suitable state to do the nesting part. I find that most word processed text is in a poor state for easy conversion to good XML that is valid to a specific schema. When based simply on paragraph and character style names the end result is often unusable. So I use temporary attributes that encode the important stylistic overrides - capturing what the author was trying to achieve. I have been very pleased with the results.
Ian
-----Original Message----- From: Wendell Piez wapiez@xxxxxxxxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Sent: 29 October 2018 20:17 To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] Nesting a flat XML structure
Hi,
Yes, what Graydon says (multiple passes).
Here's a simple pass that wraps lists recursively based on a function that determines a list level for an element in a flat sequence:
https://gitlab.coko.foundation/XSweet/XSweet/blob/master/applications/list-promote/mark-lists.xsl
It can be followed by a pass to make lists for the wrappers (in this case HTML):
https://gitlab.coko.foundation/XSweet/XSweet/blob/master/applications/list-promote/itemize-lists.xsl
Because the wrapper is abstracted, either/both the XSLTs can be modified separately.
Using XSLT 3.0 they can be chained together (poor man's pipeline) -- or of course you can Do It With Modes:
https://gitlab.coko.foundation/XSweet/XSweet/blob/master/applications/list-promote/PROMOTE-lists.xsl
However (as I think Graydon also implies), frequently the requirement is so far away from the generic, that it is easier to code it to the case.
Cheers, Wendell
On Mon, Oct 29, 2018 at 3:02 PM Graydon graydon@xxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
On Mon, Oct 29, 2018 at 06:52:59PM -0000, Martin Honnen martin.honnen@xxxxxx scripsit: [snipped examples]though so keeps the "ul" lists separated from the sibling "p" elements, have so far not understood why a list belongs into a preceding paragraph.
I have so far found that taking a word processor format flat sequence of elements and properly nesting the lists takes interpreting the source for level, labelling the list with that level (generally via disposable attribute), and then performing a distinct nesting pass where the final list item of a list "eats" the immediate follow-sibling lists if the list has a lower level-label than this list. Especially when you have complex list items (tables, multiple paragraphs, notes...) it's generally just easier to approach the problem as a sequence of passes over the content.
-- Graydon
-- Wendell Piez | http://www.wendellpiez.com XML | XSLT | electronic publishing Eat Your Vegetables _____oo_________o_o___ooooo____ooooooo_^
-- Gerrit Imsieke GeschC$ftsfC<hrer / Managing Director le-tex publishing services GmbH Weissenfelser Str. 84, 04229 Leipzig, Germany Phone +49 341 355356 110, Fax +49 341 355356 510 gerrit.imsieke@xxxxxxxxx, http://www.le-tex.de
Registergericht / Commercial Register: Amtsgericht Leipzig Registernummer / Registration Number: HRB 24930
GeschC$ftsfC<hrer / Managing Directors: Gerrit Imsieke, Svea Jelonek, Thomas Schmidt
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Nesting a flat XML struct, Peter Flynn peter@xx | Thread | Re: [xsl] Nesting a flat XML struct, ian.proudfoot@xxxxxx |
Re: [xsl] Nesting a flat XML struct, ian.proudfoot@xxxxxx | Date | Re: [xsl] Nesting a flat XML struct, Peter Flynn peter@xx |
Month |