Bug 57356 - XWPFDocument does not deal with name space xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint"
Summary: XWPFDocument does not deal with name space xmlns:wx="http://schemas.microsoft...
Status: NEEDINFO
Alias: None
Product: POI
Classification: Unclassified
Component: XWPF (show other bugs)
Version: 3.10-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-16 12:54 UTC by yang zhao
Modified: 2014-12-17 08:26 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description yang zhao 2014-12-16 12:54:19 UTC
I am now try to get the value of <wx:t wx:val="3."/>, is it possible to get it with POI API?

    <w:pPr>
        <w:pStyle w:val="ListParagraph"/>
        <w:listPr>
            <w:ilvl w:val="0"/>
            <w:ilfo w:val="3"/>
            <wx:t wx:val="3."/>
            <wx:font wx:val="Times New Roman"/>
        </w:listPr>
        <w:ind w:left="0" w:first-line="567"/>
        <w:jc w:val="left"/>
        <w:rPr>
            <w:rFonts w:ascii="仿宋_GB2312" w:fareast="仿宋_GB2312"/>
            <wx:font wx:val="仿宋_GB2312"/><w:color w:val="FF0000"/>
        </w:rPr>
    </w:pPr>
Comment 1 Nick Burch 2014-12-16 13:26:18 UTC
What did you try so far?
Comment 2 yang zhao 2014-12-17 07:24:45 UTC
I want to deal document with content like that:

五、	Level 1 header
5.1	level 2 header 
1.	level 3 header

Xml content read by XWPFDocument for them are:

<w:pStyle w:val="ListParagraph"/>
    <w:numPr>
      <w:ilvl w:val="0"/>
      <w:numId w:val="2"/>
    </w:numPr>


    <w:pStyle w:val="ListParagraph"/>
    <w:numPr>
      <w:ilvl w:val="1"/>
      <w:numId w:val="2"/>
    </w:numPr>

        <w:pStyle w:val="1"/>
    <w:numPr>
      <w:ilvl w:val="0"/>
      <w:numId w:val="5"/>
    </w:numPr>

While because the lack of namespace: xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint", the index in got lost. For example, there should be entry <wx:t wx:val="5.1"/> for level 2 header 5.1.

Is there any way by which XWPFDocument can take wx into consideration?

Still now, seems that I can only index the content by the relative position.
Comment 3 Nick Burch 2014-12-17 07:51:04 UTC
How are you trying to read it? How far do you get? What object are you expecting to find the <wx:t> object on? What do you see when you try to get it? Is it there if you dive down into the low level xmlbeans objects?
Comment 4 yang zhao 2014-12-17 08:26:55 UTC
I want to get the val from <wx:t wx:val="1."/>, in this case I want to get "1.".

1. I debug class org.apache.poi.xwpf.usermodel.XWPFDocument.java, for code: 
           // parse the document with cursor and add
            // the XmlObject to its lists
            XmlCursor cursor = ctDocument.getBody().newCursor();
            cursor.selectPath("./*");
            while (cursor.toNextSelection()) {
                XmlObject o = cursor.getObject();

Found thatin XmlObject o, content in tag <wx:t> was not there.

2. The xml for the paragraph is as below, so I tried with p.getCTP().getPPr().getNumPr(), but only getIlvl() and getgetNumId() are provided for it. org.apache.poi.xwpf.usermodel.XWPFParagraph.getCTP().getPPr().getNumPr() will return node <w:listPr>, right?

<w:p wsp:rsidR="003670EF" wsp:rsidRPr="007233F7" wsp:rsidRDefault="003670EF" wsp:rsidP="00FD47FD">
	<w:pPr>
		<w:pStyle w:val="1"/>
		<w:listPr>
			<w:ilvl w:val="0"/>
			<w:ilfo w:val="5"/>
			<wx:t wx:val="1."/>
			<wx:font wx:val="Times New Roman"/>
		</w:listPr>