You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by "PJ Fanning (JIRA)" <ji...@apache.org> on 2019/03/28 22:11:00 UTC
[jira] [Updated] (XMLBEANS-336) setLoadStripWhitespace() option
strips trailing white spaces of CDATA
[ https://issues.apache.org/jira/browse/XMLBEANS-336?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
PJ Fanning updated XMLBEANS-336:
--------------------------------
Labels: (was: 303-candidate)
> setLoadStripWhitespace() option strips trailing white spaces of CDATA
> ---------------------------------------------------------------------
>
> Key: XMLBEANS-336
> URL: https://issues.apache.org/jira/browse/XMLBEANS-336
> Project: XMLBeans
> Issue Type: Bug
> Components: XmlObject
> Affects Versions: Version 2
> Environment: Windows XP Professional
> Reporter: Yafei Zhang
> Priority: Major
>
> /**
> * When parsing a string containing CDATA into an XmlObject with the
> * setLoadStripWhitespace() option, the leading white spaces of the CDATA string are
> * preserved as expected, but the trailing white spaces still get stripped off.
> */
> import org.apache.xmlbeans.*;
> public class StripWhiteSpaceWithCDATATest {
> public static void main(String[] args) {
> String stringValue = new String("<test><name>testXmlBean</name>" +
> "<message><![CDATA[\n Hello, World \n]]></message></test>");
> try {
> XmlOptions options = new XmlOptions();
> options.setLoadStripWhitespace();
> XmlObject xmlContent = XmlObject.Factory.parse(stringValue, options);
> System.out.println("XmlObject WITH strip whitespace option: \n" +
> xmlContent.xmlText(options) + "\n");
>
> xmlContent = XmlObject.Factory.parse(stringValue);
> System.out.println("XmlObject WITHOUT strip whitespace option: \n" +
> xmlContent.xmlText() + "\n");
> } catch(XmlException e) {
> e.printStackTrace();
> }
> }
> // Results:
> //
> // XmlObject WITH strip whitespace option:
> // <test><name>testXmlBean</name><message>
> // Hello, World</message></test>
> //
> // XmlObject WITHOUT strip whitespace option:
> // <test><name>testXmlBean</name><message>
> // Hello, World
> // </message></test>
> //
> }
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org