Bug 64837 - In POI 3.17 xmlText prints the inner string of the CTText element (as fragment) instead of the whole xml node with <w:t>
Summary: In POI 3.17 xmlText prints the inner string of the CTText element (as fragmen...
Status: RESOLVED CLOSED
Alias: None
Product: POI
Classification: Unclassified
Component: XWPF (show other bugs)
Version: unspecified
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-10-21 11:58 UTC by NadavB
Modified: 2021-10-13 10:49 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description NadavB 2020-10-21 11:58:33 UTC
// Why print fragment instead of <w:t>?
        CTText tmpTextNode = CTText.Factory.newInstance();
        tmpTextNode.setStringValue("A");
        XmlOptions opts = new XmlOptions();
        opts.setSaveOuter();
        opts.setSaveNoXmlDecl();
        System.out.println(tmpTextNode.xmlText(opts));
Comment 1 Nick Burch 2020-10-21 12:02:41 UTC
Apache POI 3.17 is over 3 years old now - http://poi.apache.org/devel/history/changes-3x.html#3.17 . A large number of fixes have been done since then, see
http://poi.apache.org/changes.html

Can you please try again with a recent supported version, and see if the bug still remains?
Comment 2 NadavB 2020-10-21 12:17:30 UTC
Hi Nick,
Before I invest a lot of time in upgrading, can you tell me what's the desried behaviour? Should it print <w:t>... or <xml-fragment>... ?
Can you tell me what these 6 lines print in your updated POI?
Comment 3 Sayi 2020-10-27 08:09:27 UTC
Hi, NadavB

I am not sure if it can be done: output <w:t>?

But you can contact xml String by yourself and pay attention the "xmlns" attribute.
Comment 4 NadavB 2020-10-30 14:24:10 UTC
Hi Sayi,
If I'm not wrong, CTText is an XML-bean represenation of a <w:t> xml node, isn't it?
If so, I'm just trying to print out the node, as xml-string representation of the CTText element.
Comment 5 PJ Fanning 2021-10-13 10:49:49 UTC
xmlText is a generated method - we use XMLBeans to generate CTText.

xmlText has behaved this way for years - so there is no recent regression. XMLBeans 2.6.0 has this behaviour (released 2012) - as does recent XMLBeans releases.

I moved this to https://issues.apache.org/jira/browse/XMLBEANS-573