xsl-list
[Top] [All Lists]

Re: [xsl] Nesting a flat XML structure

2018-10-29 16:04:40
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(_at_)wendellpiez(_dot_)com 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> 
Sent: 29 October 2018 20:17
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
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(_at_)marost(_dot_)ca 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:

On Mon, Oct 29, 2018 at 06:52:59PM -0000, Martin Honnen 
martin(_dot_)honnen(_at_)gmx(_dot_)de 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_^
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>