Page 1 of 1

Get Numbering Parts

PostPosted: Tue Sep 23, 2014 12:51 am
by Vepe
Hi everybody!

I'm quite new with docx4j and I'm having a few problems trying to extract the numbering parts text.
I can extract the bullets and simple lists like a), b), c)... but lists like 1, 1.1, 1.1.1, 1.2, 1.2.1, ... returns null.
Am I doing something wrong?


My code:
Code: Select all
     ResultTriple rt = org.docx4j.model.listnumbering.Emulator.getNumber(
                                wordMLPackage, pStyleVal, numId, levelId);
     if(rt!=null)
     {
                System.out.println("Bullet: " + rt.getBullet());
                System.out.println("NumString: " + rt.getNumString());
      }   
               



I'm attaching my test file.

Thanks in advance.

Re: Get Numbering Parts

PostPosted: Tue Sep 23, 2014 9:18 am
by jason
Hi there, you've got the right basic idea.

If you run your docx through the ConvertOutHtml sample, you'll see the numbers are generated correctly.

So the problem must be in the parameters you are passing to Emulator.

Emulator was designed primarily, to be invoked by Xalan extension functions.

For invocation from user code, it would be convenient to have a simple method getNumber(P p).

Re: Get Numbering Parts

PostPosted: Sat Sep 27, 2014 1:19 am
by Vepe
Thanks for the response!

I will try different parameters. :)

But... One thing that I noticed is that my code works for the default numbering style.
My docx has a numbering style that I created for my personal need. I think that's the problem.


Thanks for your help!

Re: Get Numbering Parts

PostPosted: Sat Sep 27, 2014 8:19 am
by jason
Vepe wrote:My docx has a numbering style that I created for my personal need. I think that's the problem.


That shouldn't be the problem. Emulator is intended to work with arbitrary numbering, and as per my previous post, does work with your docx (when passed the correct parameters!).