Page 1 of 1

list items

PostPosted: Sat May 12, 2018 7:08 am
by laurenquintanilla
are there methods to help find which list items belong together when they don't have the same numId.
For example, in word, these display as the same list - one at level 2 and the next at level 3 -- but in the xml, they have different numId values

<w:p w:rsidR="000C6B97" w:rsidRDefault="00E80511" w:rsidP="00E80511">
<w:pPr>
<w:numPr>
<w:ilvl w:val="2"/>
<w:numId w:val="35"/>
</w:numPr>
<w:spacing w:after="0"/>
<w:ind w:left="1200"/>
</w:pPr>
<w:r>
<w:rPr>
<w:color w:val="000000"/>
</w:rPr>
<w:t>Here is the level 2 text
</w:t>
</w:r>
<w:r>
<w:br/>
</w:r>
<w:r>
<w:br/>
</w:r>
</w:p>
<w:p w:rsidR="000C6B97" w:rsidRDefault="00E80511" w:rsidP="00E80511">
<w:pPr>
<w:numPr>
<w:ilvl w:val="3"/>
<w:numId w:val="36"/>
</w:numPr>
<w:spacing w:after="0"/>
<w:ind w:left="1800"/>
</w:pPr>
<w:r>
<w:rPr>
<w:b/>
<w:color w:val="000000"/>
</w:rPr>
<w:t>No:</w:t>
</w:r>
<w:r>
<w:rPr>
<w:color w:val="000000"/>
</w:rPr>
<w:t xml:space="preserve"> Here is the level 3 text, but it has a different numId</w:t>
</w:r>
</w:p>

Re: list items

PostPosted: Sat May 12, 2018 8:29 am
by jason
You look at the numbering part for those numIds, and see what abstract list number each refers to. If its the same one, then in that sense they are the same list.

Re: list items

PostPosted: Sat May 12, 2018 9:43 am
by laurenquintanilla
Thanks!
So, from a numId, I can grab the formatting based on level from the AbstractListNumberingDefinition. I then check for overrides in ListNumberingDefinition. Is there a way to get all numIds that have the same AbstractListNumberingDefinition so I can also check for any overrides on the other levels?

Re: list items

PostPosted: Sat May 12, 2018 8:06 pm
by jason
Not quite. the numId points to the override/concrete list, which in turn points to the abstract list. If the formatting isn't defined in the override, then look for it in the abstract list.

Any given level could appear differently throughout the document, simply by using a numid pointing to a different override. The thing to bear in mind is that each abstract list has its own counters, which increment whenever used in the document.

See org.docx4j.model.listnumbering.Emulator (the code there is messy and really needs to be cleaned up, though it does work)

For example, HTMLExporterVisitorGenerator uses it like so:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
                ResultTriple triple = org.docx4j.model.listnumbering.Emulator.getNumber(
                                conversionContext.getWmlPackage(), pStyleVal, numId, levelId);  
               

                        if (triple==null) {
                                getLog().debug("computed number ResultTriple was null");
                } else {
                                if (triple.getBullet() != null) {
                                        //numberText = (triple.getBullet() + " ");
                                        numberText = "\u2022  ";
                                } else if (triple.getNumString() == null) {
                                        getLog().error("computed NumString was null!");
                                        numberText = ("?");
                                } else {
                                        numberText = (triple.getNumString() + " ");
                                }
                }
 
Parsed in 0.016 seconds, using GeSHi 1.0.8.4

Re: list items

PostPosted: Tue May 15, 2018 3:34 am
by laurenquintanilla
From the example above, when processing <w:p>
<w:pPr>
<w:numPr>
<w:ilvl w:val="3"/>
<w:numId w:val="36"/>
with xslt, how can I tell if there was a level 2, level1, level 0 for this list if the numId values differ.

Thanks for your help!

Re: list items

PostPosted: Wed May 16, 2018 8:38 am
by jason
Hi Lauren, what are you trying to achieve exactly?

as an aside, I replied to your emails of 20 April and 1 May immediately, but I suspect you didn't see the replies for some reason. My replies asked for a sample docx.

cheers .. Jason

Re: list items

PostPosted: Thu May 17, 2018 4:32 am
by laurenquintanilla
Thanks for the replies - not sure why they didn't come through; I will do some checking. We did find a solution for that issue though to turn off the track changes for formatting changes.

On this issue, we are trying to generate markdown from Word. Attached is a simple example of the issue.

Say I have
1. List item 1
-bullet1
-bullet2
2. List item2.

The markdown would be
1. List item1
1*. bullet1
1*. bullet2
2. List item2.

When doing the markdown for 'bullet2', I need to know it's parent list item to generate the markdown correctly - to know if the parent was ordered or unordered. If parent was unordered, then the markdown for 'bullet2' would be ** bullet1. For bullet1, I can just look at the <w:p> preceeding sibling, but what about bullet2. of all the preceeding siblings, how can we tell which one related to 'bullet2'? In Word, sometimes these lists have different numIds and sometimes they go from level 0 for 'List item1' in the attached case to level0 for bullet2.

Somehow you handle this with the html conversion. Are there methods in docx4j to help determine the parent list item?

Thanks!!

Re: list items

PostPosted: Thu May 17, 2018 4:35 am
by laurenquintanilla
typo on the previous post:
The markdown would be
1. List item1
1*. bullet1
1*. bullet2
1. List item2.


And using XSLT to convert